为什么安装在虚拟环境中的模块在 bash 可用而不是闲置?
Why module installed in virtual environment is available in bash and not in idle?
我是 运行 Ubuntu 18.04.5 LTS
系统范围 python 版本是 2.7.17(显然),我还设置了多个虚拟环境。今天发生了一件我还不明白的事情,就是:
我激活了我的 (3.8) 环境
然后下载了一个模块:
(3.8) $ pip install algorithms
启动空闲-python3.8:
(3.8) $ idle-python3.8 &
尝试导入我刚下载的模块:
>>> import algorithms
然后,我看到弹出这个错误:
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
import algorithms
ModuleNotFoundError: No module named 'algorithms'
我关闭空闲并确保模块已安装:
(3.8) $ pip list
Package Version
---------------------- -------
algorithms 0.1.4
astroid 2.4.2
autopep8 1.5.4
backcall 0.2.0
decorator 4.4.2
......
.....
我必须确保...:[=18=]
(3.8) $ python --version
Python 3.8.0
然后我试了这个:
(3.8) $ python3.8
Python 3.8.0 (default, Oct 28 2019, 16:14:01)
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import algorithms
>>>
什么?!如何?!有人可以启发我吗?谢谢
在全局环境中空闲运行。你必须这样开始:
python -m idlelib.idle
在此处查看详细答案:
How to launch python Idle from a virtual environment (virtualenv)
我是 运行 Ubuntu 18.04.5 LTS
系统范围 python 版本是 2.7.17(显然),我还设置了多个虚拟环境。今天发生了一件我还不明白的事情,就是:
我激活了我的 (3.8) 环境
然后下载了一个模块:
(3.8) $ pip install algorithms
启动空闲-python3.8:
(3.8) $ idle-python3.8 &
尝试导入我刚下载的模块:
>>> import algorithms
然后,我看到弹出这个错误:
Traceback (most recent call last): File "<pyshell#0>", line 1, in <module> import algorithms ModuleNotFoundError: No module named 'algorithms'
我关闭空闲并确保模块已安装:
(3.8) $ pip list Package Version ---------------------- ------- algorithms 0.1.4 astroid 2.4.2 autopep8 1.5.4 backcall 0.2.0 decorator 4.4.2 ...... .....
我必须确保...:[=18=]
(3.8) $ python --version Python 3.8.0
然后我试了这个:
(3.8) $ python3.8 Python 3.8.0 (default, Oct 28 2019, 16:14:01) [GCC 8.3.0] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import algorithms >>>
什么?!如何?!有人可以启发我吗?谢谢
在全局环境中空闲运行。你必须这样开始:
python -m idlelib.idle
在此处查看详细答案: How to launch python Idle from a virtual environment (virtualenv)