Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Installing numpy for Python 2.7 while also having Python 3.4 installed?

I have both Python 2.7 and Python 3.4 (and have to have both because for the class I'm running, students have the option of using either). One student has used Python 2.7 and numpy for their project, but when I attempt to install numpy, it installs it to 3.4. I need to install it to 2.7.

I'm using numpy 1.9 from this site, which I'm told is also 2.7-specific: http://sourceforge.net/projects/numpy/files/NumPy/

However, nonetheless it still goes to the 3.4 folder. Copying it to Python 2.7 didn't work, obviously.

How do I do this?

like image 264
David Avatar asked Sep 17 '14 21:09

David


3 Answers

Assuming that you are using, or at least you should use pip to install the library. You can specify the python version to be installed by changing the suffix, e.g. pip-2.7 install numpy.

pip install numpy
pip-2.7 install numpy
pip-3.4 install numpy

As an alternative, in case that you do not want to use pip is to download and install the library using setup with a similar technique.

python setup.py install
python2.7 setup.py install
python3.4 setup.py install
like image 113
eandersson Avatar answered Oct 23 '22 22:10

eandersson


Your PATH isn't setup correctly.

C:> where pip

Should tell you which pip it is trying to use, and it is likely whichever one it found on your PATH first...

So, instead, you will want to run it as

C:> C:\mypython2install\pip.exe install numpy

Or, setup your path correctly. See here

like image 32
jakebrinkmann Avatar answered Oct 23 '22 22:10

jakebrinkmann


I recommend installing with pip.

pip install numpy

If this doesn't work on windows then download the binary from http://www.lfd.uci.edu/~gohlke/pythonlibs/ and convert it to a wheel before installing.

pip install wheel
wheel convert path/to/binary
pip install numpy_wheel 

Pip is recommended because you can uninstall.

To check where you are installing to

pip -V

You may have an environmental variable path to the wrong pip.

like image 2
justengel Avatar answered Oct 23 '22 22:10

justengel