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

余生颓废 提交于 2019-12-05 01:23:20

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.

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
jakebrinkmann

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

Just one other note on issues like this. I had a similar problem with Python 2.7 libraries not being found, because I had miniconda installed for a Python virtual environment that was hijacking calls to python from other programs. After deleting the minconda directory in my home the problem went away and python libraries that were properly installed were found again.

Note-This answer is particularly for Windows PC which has both Python2 & Pyhton3 installed on it.

Both the versions of Python has their different directories somewhat like

"C:\Python27\" ----for python2

"C:\Python35\" ---- for python3

*(or it depends on what path you chose while installing Python**)*

pip GENERALLY exist under the directory "C:\Python**\Scripts"

there you can find exe files like:

pip.exe/pip2.exe/pip2.7.exe ----for python2

pip3.exe/pip3.5.exe ----for python3

to install packages on python2:

use

Python27\Scripts\pip2.exe install package_name

(where the 1st argument is the path of exe file, it might differ for your system)

to install packages on python3:

use

Python35\Scripts\pip3.exe install package_name

there is no need to uninstall any version of python to achieve the task.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!