[Distutils] Problems using pip on Ubuntu when 2.7, 3.4 and 3.5 are installed

Nick Coghlan ncoghlan at gmail.com
Sat Jan 9 04:26:32 EST 2016


On 8 January 2016 at 19:18, ars technica <arstechnica at contractor.net> wrote:
> Hi,
>
> thank you for the tutorial here
> https://docs.python.org/3.5/installing/index.html
>
> I have a problem using pip to install packages to 3.5. I now have three
> versions installed and pip only addresses the two old ones.
>
> The command pip installs to 2.7
> pip3 installs to 3.4 and that leaves 3.5 all alone.
>
> I tried to install numpy with the command
> python3.5 -m pip install numpy

In the absence of a virtual environment, using "-m" as you have done
here is the right way to invoke pip while ensuring it's using the
intended Python installation.

> but got the error that Python.h could not be located. When asked bash
> locate Python.h
>    it returned
> /usr/local/include/python3.4m/Python.h

This is where things can get a bit messy, since Linux tends to assume
system-wide builds by default.

> My question therefore is. How do I setup my environment to be able to
> install packages to all the Python versions? Should I do a
> virtualenvironment for each version or can I change some configuration file
> to let PIP know that it should check the Py3.5 folder when desired?

If you're fine with building NumPy from source yourself, then creating
a virtual environment for each version should work. However, I believe
there may still be some potential to end up running into missing
header files for some of NumPy's external dependencies when building
for a Python version that wasn't provided by your distro.

If you'd prefer to avoid any configuration and debugging of
C/C++/FORTRAN build processes, then you may prefer to grab miniconda
and download distro-independent pre-built binaries:
http://conda.pydata.org/miniconda.html

Cheers,
Nick.

-- 
Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia


More information about the Distutils-SIG mailing list