[英]how to import newly installed python module in launched interactive session?
I am running python interactive session in one terminal window, and then just installed numpy in another terminal window. 我在一个终端窗口中运行python交互式会话,然后将numpy安装在另一个终端窗口中。 How could I import numpy
in the running interactive session without exiting it and relaunching it? 如何在正在运行的交互式会话中import numpy
而不退出并重新启动它?
The answer is that you shouldn't have to do anything special. 答案是您不必做任何特别的事情。
% 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'>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.