繁体   English   中英

安装在 venv 中的模块无法识别

[英]Modules installed in venv are not recognized

为什么它不起作用? Django.tar.gz 直接来自 PyPi,如果我尝试“python -m pip install”它可以工作,但会全局安装 python。

(newenv) [root]# pip install paczki/Django-2.0.7.tar.gz
pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
Processing ./paczki/Django-2.0.7.tar.gz
Requirement already satisfied: pytz in ./newenv/lib/python3.6/site-packages (from Django==2.0.7)
Installing collected packages: Django
  Running setup.py install for Django ... done
Successfully installed Django-2.0.7
(newenv) [root]# python3
Python 3.6.0 (default, May 22 2018, 12:59:04)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-16)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import django
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'django'
>>>

想通了这一点。 之前有人设置了一个系统范围的别名,将 python 别名为“/A/B/python”等特定路径,因此即使在 venv 中使用的 python 也是这个。 :which python: 可能会产生误导 - id 不检查别名,因此 :which python: 和 :python: 没有指向同一个。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM