问题描述
我有一个从虚拟环境安装的软件包.如果我只是启动 python 解释器,则可以很好地导入该包.但是,如果我启动 Idle,则无法导入该包(因为它仅在一个特定的 virtualenv 中可用而不是在全局中可用).如何从 virtualenv 启动 Idle,以便 virtualenv 中的所有包都可用?
I have a package that I installed from a virtual environment. If I just launch the python interpreter, that package can be imported just fine. However, if I launch Idle, that package cannot be imported (since it's only available in one particular virtualenv and not global). How can I launch Idle from a virtualenv, so that all packages from the virtualenv would be available?
推荐答案
对于 Python 3.6+,请参阅下面 Paul Wicking 的回答一>.
For Python 3.6+, please see Paul Wicking's answer below.
在 Python 3.6 之前,IDLE 本质上是
In Python prior to 3.6, IDLE is essentially
from idlelib.PyShell import main
if __name__ == '__main__':
main()
所以你可以自己启动它,除非你在没有默认包的情况下构建了 virtualenv.
So you can launch it yourself unless you built the virtualenv without default packages.
这篇关于如何从虚拟环境 (virtualenv) 启动 python Idle的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!