How to install Python package from source on Windows

Mark Summerfield m.n.summerfield at googlemail.com
Tue May 16 05:30:15 EDT 2017


I think the problem that Deborah has encountered is a more general one on
Windows: many pip-installable packages assume that a C compiler is
available.

Now an "obvious" solution is for pip to recognise that a C compiler is
needed and give an appropriate error message. But while that may reduce
confusion, it won't actually help someone who wants to install a Python
package that needs a C compiler.

Of course, the error message could give a link to the appropriate
compiler. And then the user (who presumably isn't a Windows compiler
expert) will if they're really lucky get to download and install an
enormous Visual Studio compiler. Of course they may not be so lucky and
may discover that the installer tells them that they need some component
(and may or may not give the link to get it). And then they get that
component and, you guessed it, that component says it needs another
component, ... and eventually you end up with all the pieces. And even
then it doesn't necessarily work. (This has happened to me more than
once.)

Here's a fantasy:

C:\> pip install pkg_needs_c
Error: the pkg_needs_c package needs development tools which haven't been
found on this computer.
Run pip install --listtools pkg_needs_c for information on the required
tools or run pip install --useprebuilt pkg_needs_c to download prebuilt
components so no additional development tools are needed.

C:\> pip install --listtools pkg_needs_c
The pkg_needs_c needs Visual Studio 2015 (which itself may have additional
dependencies). This can be downloaded from http://www....

C:\> pip install --useprebuilt pkg_needs_c
...

This will send the minimum necessary details of the machine back to PyPI
which will then do a request on a Windows server farm which will send back
a matching pre-built package (building the package the first time it is
needed).

I have no idea if this is possible/practical!

But I do think that installing dev tools on Windows can be really difficult (esp. if you're on older versions of Windows, e.g., XP, Vista, or 7) and that this can make things hard for people coming to Python on Windows. I guess the best that can be done for now is to recommend Annaconda or a similar distro with lots of prebuilt stuff.



More information about the Python-list mailing list