我在一个终端窗口中运行python交互式会话,然后在另一个终端窗口中安装numpy。在没有退出并重新启动它的情况下,如何在正在运行的交互式会话中import numpy
?
答案 0 :(得分:1)
答案是你不应该做任何特别的事情。
% virtualenv foo
New python executable in foo/bin/python
Installing setuptools............done.
Installing pip...............done.
% foo/bin/python
Python 2.7.3 (default, Sep 8 2012, 23:11:27)
[GCC 4.2.1 Compatible Apple Clang 4.0 ((tags/Apple/clang-421.0.60))] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named numpy
>>>
Suspended
% foo/bin/pip install numpy
Downloading/unpacking numpy
% fg
>>> import numpy
>>> numpy
<module 'numpy' from '/.../foo/lib/python2.7/site-packages/numpy/__init__.pyc'>