无法在虚拟环境下安装最新的numpy和scipy

时间:2015-12-01 15:53:03

标签: python numpy scipy pip python-venv

我一直在努力升级/安装numpy和scipy到我的venv下的最新版本。想要升级的原因是在venv:

下运行我的脚本时的错误
(venv)[malapradej@lotus Code]$ python2.7 create_emulator_ap_680-755.py --sza 80 --vza 80 --raa 180 --train /work/scratch/malapradej/DASF/Data/LUT_ap/lhd250_train_ap1 --validate /work/scratch/malapradej/DASF/Data/LUT_ap/lhd300_valid_ap1 --plot n

RuntimeError: module compiled against API version 9 but this version of numpy is 7
Traceback (most recent call last):
  File "./create_emulator_ap_680-755.py", line 57, in <module>
    import gp_emulator
  File "/home/users/malapradej/venv/lib/python2.7/site-packages /gp_emulator/__init__.py", line 3, in <module>
    from multivariate_gp import MultivariateEmulator
  File "/home/users/malapradej/venv/lib/python2.7/site-packages/gp_emulator/multivariate_gp.py", line 32, in <module>
    import h5py
  File "/home/users/malapradej/venv/lib/python2.7/site-packages/h5py/__init__.py", line 23, in <module>
    from . import _conv
  File "h5py/h5t.pxd", line 14, in init h5py._conv (/tmp/pip-build-JA5F4M/h5py/h5py/_conv.c:6970)
  File "h5py/h5t.pyx", line 1, in init h5py.h5t (/tmp/pip-build-JA5F4M/h5py/h5py/h5t.c:19707)
ImportError: numpy.core.multiarray failed to import

在venv下我跑了:

pip install -Iv numpy==1.10.1

pip install -Iv --upgrade numpy==1.10.1

每次结束时:

Successfully installed numpy-1.7.0
Cleaning up...

当我使用蛋黄查看使用的包时:

yolk -l | grep numpy

numpy           - 1.10.1       - non-active
numpy           - 1.7.0        - active development (/usr/lib/python2.7/site-packages)
numpy           - 1.9.2        - non-active

我似乎已下载该软件包,但未升级并激活它。

如果我运行ipython,它似乎有效:

In [1]: import numpy as np

In [2]: print np.__version__
1.10.1

但是在python2.7下它显示的是早期版本:

(venv)[malapradej@cems-sci1 venv]$ python2.7

>>> import numpy as np
>>> np.__version__
'1.7.0'

同样的scipy。

非常感谢,

1 个答案:

答案 0 :(得分:0)

我唯一的选择是删除旧的virtualenv并使用virtualenv --system-site-packages ~/venv重新安装,并使用pip install --upgrade <package>再次重新安装。似乎某个地方的venv已经腐败,并试图弄清楚这发生的时间会花费太长时间。