Installing packages not yet on pip as wheels
suggest changeMany pure-Python packages are not yet available on the Python Package Index as wheels, but they still install from source. However, some packages on Windows give the dreaded vcvarsall.bat not found error.
The problem is that the package that you are trying to install contains a C or C++ extension and is not currently available as a pre-built wheel from the python package index, pypi, and on windows you do not have the tool chain needed to build such items.
The simplest answer used to be Christoph Gohlke’s site of unofficial Windows wheels. That UCI collection was discontinued in 2022, so the link is not a current package index. The filename tags below are still how those wheels were named. Locate the appropriate version of the libraries that you need. By appropriate in the package name a -cpNN**-** has to match your version of python, i.e. if you are using windows 32 bit python even on win64 the name must include -win32- and if using the 64 bit python it must include -win_amd64- and then the python version must match, i.e. for Python 34 the filename must include -cp34-, etc. this is basically the magic that pip does for you on the pypi site.
Alternatively, you need to get the appropriate windows development kit for the version of python that you are using, the headers for any library that the package you are trying to build interfaces to, possibly the python headers for the version of python, etc.
Then you may need to locate the header files, at the matching revision for any libraries that your desired package links to and download those to an appropriate location.
Finally you can let pip do your build - of course if the package has dependencies that you don’t yet have you may also need to find the header files for them as well.
Alternatives: It is also worth looking out, both on pypi or Christoph’s site, for any slightly earlier version of the package that you are looking for that is either pure python or pre-built for your platform and python version and possibly using those, if found, until your package does become available. Likewise if you are using the very latest version of python you may find that it takes the package maintainers a little time to catch up so for projects that really need a specific package you may have to use a slightly older python for the moment. You can also check the packages source site to see if there is a forked version that is available pre-built or as pure python and searching for alternative packages that provide the functionality that you require but are available - one example that springs to mind is Pillow, an actively maintained drop-in replacement for PIL, which is unmaintained and not available for Python 3.
Afterword, I would encourage anybody who is having this problem to go to the bug tracker for the package and add to, or raise if there isn’t one already, a ticket politely requesting that the package maintainers provide a wheel on pypi for your specific combination of platform and python, if this is done then normally things will get better with time, some package maintainers don’t realise that they have missed a given combination that people may be using.
Note on Installing Pre-Releases
pip follows PEP 440. By default it prefers final releases over pre-releases. If a package has a final release 0.98 and a release candidate 1.0rc1, pip install installs 0.98. To install the candidate, test in a virtual environment first, then run pip install --pre package-name or pip install --pre --upgrade package-name. V1.0-rc1 is not a PEP 440 version. In many cases pre-releases or release candidates may not have wheels built for all platform and version combinations, so you are more likely to encounter the issues above.
Note on Installing Development Versions
You can also use pip to install development versions of packages from github and other locations, since such code is in flux it is very unlikely to have wheels built for it, so any impure packages will require the presence of the build tools, and they may be broken at any time so the user is strongly encouraged to only install such packages in a virtual environment.
Three options exist for such installations:
- Download compressed snapshot, most online version control systems have the option to download a compressed snapshot of the code. This can be downloaded manually and then installed with
pip installpath/to/downloaded/file note that for most compression formats pip will handle unpacking to a cache area, etc. - Let pip handle the download & install for you with:
pip installURL/of/package/repository - you may also need to use the--trusted-host,--client-certand/or--proxyflags for this to work correctly, especially in a corporate environment. e.g:
Note the git+ prefix to the URL.
- Clone the repository using
git,mercurialor other acceptable tool, preferably a DVCS tool, and usepip installpath/to/cloned/repo. That installs the project from its own metadata. It does not automatically install arequirements.txt. You can runpip install -r requirements.txtyourself if the repository has that file, and then install the project. Directpython setup.py installis deprecated. The big advantage of this approach is that while the initial clone operation may take longer than the snapshot download you can update to the latest with, in the case of git:git pull origin master(use the repository's default branch if it is notmaster) and if the current version contains errors you can usepip uninstallpackage-name then usegit checkoutcommands to move back through the repository history to earlier version(s) and re-try.