所以我导航到我的虚拟环境。
激活它
做pip install requests
安装
我转到文件然后import requests
然后得到这个错误:
No module named request less... (Ctrl+F1)
This inspection detects names that should resolve but don't. Due to dynamic dispatch and duck typing, this is possible in a limited but useful number of cases. Top-level and class-level items are supported better than instance items.
我再次点击安装只是为了看到我得到了这个:
pip install requests
Requirement already satisfied: requests in ./lib/python2.7/site-packages
Requirement already satisfied: certifi>=2017.4.17 in ./lib/python2.7/site-packages (from requests)
Requirement already satisfied: chardet<3.1.0,>=3.0.2 in ./lib/python2.7/site-packages (from requests)
Requirement already satisfied: idna<2.7,>=2.5 in ./lib/python2.7/site-packages (from requests)
Requirement already satisfied: urllib3<1.23,>=1.21.1 in ./lib/python2.7/site-packages (from requests)
我在django项目中使用pycharm。我不认为这些问题只是为了以防万一。
答案 0 :(得分:1)
答案是我的pycharm软件设置为python的全局安装,而不是我的虚拟环境实例。我必须按照以下说明设置pycharm以使用该env实例:
http://exponential.io/blog/2015/02/10/configure-pycharm-to-use-virtualenv/