简体   繁体   中英

unable to import requests after installing in virtual environment python 2.7 pycharm

so I navigate to my virtual environment.

Activate it

do pip install requests

it installs

i go to a file and then import requests

then get this error:

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.

i did pip install again just to see and I get this:

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)

Im using pycharm and in a django project. I dont think either of those matter but just in case.

The answer was that my pycharm software was set to the global install of python not my virtual env instance. I had to set up pycharm to use that env instance, by following the instructions here:

http://exponential.io/blog/2015/02/10/configure-pycharm-to-use-virtualenv/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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