如何为python 2.7.9安装numpy

时间:2017-01-03 17:12:10

标签: python python-2.7 numpy

我有两个版本的python-2.7.6&为python 2.7.6安装了2.7.9和numpy。我无法理解如何为python 2.7.9安装numpy。

当我使用pip2 install --upgrade numpy时,它会安装和更新python 2.7.6。

如何为python 2.7.9特别安装numpy?

*****编辑*****

我想找到python 2.7.9的位置。

如果我输入pythonpython2,我使用的是python 2.7.9。 which -a python给了我两条路径/usr/bin/python/usr/local/bin/python,当我使用第一条路径时,它给了我这个输出 - Requirement already satisfied (use --upgrade to upgrade): numpy in /usr/local/lib/python2.7/dist-packages Cleaning up...

如果我使用第二条路径,我会得到这个输出 - /usr/local/bin/python: No module named pip

which -a pip命令提供/usr/local/bin/pip /usr/bin/pip

which -a easy_install提供/usr/local/bin/easy_install /usr/bin/easy_install

which -a python提供/usr/local/bin/python /usr/bin/python

***** EDIT2 *****

我的操作系统是Ubuntu 14.04lts。

/usr/local/bin/pip --version给出pip 1.5.4 from /usr/lib/python2.7/dist-packages (python 2.7)

/usr/bin/pip --version提供pip 1.5.4 from /usr/lib/python2.7/dist-packages (python 2.7)

/usr/local/bin/easy_install --version提供setuptools 32.1.2 from /usr/local/lib/python2.7/dist-packages (Python 2.7)

/usr/bin/easy_install --version提供setuptools 3.3

/usr/local/bin/python --version提供Python 2.7.9

/usr/bin/python --version提供Python 2.7.6

***** EDIT3 *****

sudo /usr/local/bin/easy_install pip提供以下输出 -

Searching for pip
Best match: pip 1.5.4
Adding pip 1.5.4 to easy-install.pth file
Installing pip script to /usr/local/bin
Installing pip2.7 script to /usr/local/bin
Installing pip2 script to /usr/local/bin

Using /usr/lib/python2.7/dist-packages
Processing dependencies for pip
Finished processing dependencies for pip

***** edit4 *****

sys.path = [
'/home/kevmepls',
'/home/kevmepls/Documents/DeepLearning-Caffe/caffe/python',
'/usr/local/lib/python27.zip',
'/usr/local/lib/python2.7',
'/usr/local/lib/python2.7/plat-linux2',
'/usr/local/lib/python2.7/lib-tk',
'/usr/local/lib/python2.7/lib-old',
'/usr/local/lib/python2.7/lib-dynload',
'/home/kevmepls/.local/lib/python2.7/site-packages',
'/usr/local/lib/python2.7/site-packages',
]
USER_BASE: '/home/kevmepls/.local' (exists)
USER_SITE: '/home/kevmepls/.local/lib/python2.7/site-packages' (exists)
ENABLE_USER_SITE: True

2 个答案:

答案 0 :(得分:4)

像这样:

/path/to/python279 -m pip install --user numpy

如果您看到错误No module named pip,请先按照以下说明安装pip:

  1. 下载此文件:get_pip.py
  2. 执行sudo /path/to/python279 get_pip.py
  3. 再试一次/path/to/python279 -m pip install --user numpy

答案 1 :(得分:0)

我相信这与你的路径变量有关。目前,我相信你的路径变量指向你安装的Python 2.7.6。检查python的路径变量,并希望将其更改为正确的安装可以解决您的问题。