我一直在努力将 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 查看使用了哪些包时:
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 也是如此。
非常感谢帮助,