如何在启动的交互式会话中导入新安装的python模块?

如何在启动的交互式会话中导入新安装的python模块?,python,import,Python,Import,我在一个终端窗口中运行python交互式会话,然后在另一个终端窗口中安装了numpy。如何在运行交互式会话时导入numpy而不退出并重新启动它?答案是您不必做任何特殊的事情 % virtualenv foo New python executable in foo/bin/python Installing setuptools............done. Installing pip...............done. % foo/bin/python Python 2.7.3 (d

我在一个终端窗口中运行python交互式会话,然后在另一个终端窗口中安装了numpy。如何在运行交互式会话时导入numpy而不退出并重新启动它?

答案是您不必做任何特殊的事情

% 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'>
%virtualenv foo
foo/bin/python中的新python可执行文件
安装安装工具…………完成。
安装管道…………完成。
%foo/bin/python
Python 2.7.3(默认值,2012年9月8日23:11:27)
达尔文上的[GCC 4.2.1兼容Apple Clang 4.0((tags/Apple/Clang-421.0.60))]
有关详细信息,请键入“帮助”、“版权”、“信用证”或“许可证”。
>>>进口numpy
回溯(最近一次呼叫最后一次):
文件“”,第1行,在
ImportError:没有名为numpy的模块
>>> 
暂停的
%foo/bin/pip安装numpy
下载/解包numpy
%前景
>>>进口numpy
>>>努比

如果
numpy
是作为一个egg安装的,并且必须有自己的
.pth
文件条目,Python会在运行时获取它吗?对我来说不是这样,但我使用的是ipython。这会有区别吗?如果我更新一个包呢?它会在交互式会话中更新吗?