我曾经使用 pip 在装有旧版 Numpy 的计算机上更新并安装了一些库。但它似乎并没有真正应用:
davidm@illergard:~$ python
Python 2.7.3 (default, Feb 27 2014, 19:58:35)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
>>> numpy.__version__
'1.6.1'
另一方面,Ipython 确实看到了新的库:
davidm@illergard:~$ ipython
Python 2.7.3 (default, Feb 27 2014, 19:58:35)
Type "copyright", "credits" or "license" for more information.
IPython 2.1.0 -- An enhanced Interactive Python.
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help -> Python's own help system.
object? -> Details about 'object', use 'object??' for extra details.
In [1]: import numpy
In [2]: numpy.__version__
Out[2]: '1.8.1'
这表明 Ipython 正在运行不同的 Python。让我们看看:
davidm@illergard:~$ which python
/usr/bin/python
davidm@illergard:~$ which ipython
/usr/local/bin/ipython
davidm@illergard:~$ cat /usr/local/bin/ipython
#!/usr/bin/python
# EASY-INSTALL-ENTRY-SCRIPT: 'ipython==2.1.0','console_scripts','ipython'
__requires__ = 'ipython==2.1.0'
import sys
from pkg_resources import load_entry_point
if __name__ == '__main__':
sys.exit(
load_entry_point('ipython==2.1.0', 'console_scripts', 'ipython')()
)
shebang 对应的是同一个 Python!Virtualenv 没有安装,所以这不是问题。
系统信息:
davidm@illergard:~$ uname -a
Linux illergard 3.2.0-65-generic #99-Ubuntu SMP Fri Jul 4 21:03:29 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux
davidm@illergard:~$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 12.04.4 LTS
Release: 12.04
Codename: precise
有关的:https://stackoverflow.com/questions/9386048/ipython-reads-wrong-python-version
答案1
我不知道原因,如果有人能指出我会很高兴,但我找到了解决办法。运行
sudo python ez_setup.py
从ez_setup.py 在此处获取,奇迹般地解决了这个问题,现在 python 可以看到更新的库。无需重新安装。