I'm having trouble with using 'requests' module on my Mac. I use python34 and I installed 'requests' module via pip. I can verify this via running installation again and it'll show me that module is already installed.
15:49:29|mymac [~]:pip install requests
Requirement already satisfied (use --upgrade to upgrade): requests in /opt/local/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages
Although I can import 'requests' module via interactive Python interpreter, trying to execute 'import requests' in PyCharm yields error 'No module named requests'. I checked my PyCharm Python interpreter settings and (I believe) it's set to same python34 as used in my environment. However, I can't see 'requests' module listed in PyCharm either.
It's obvious that I'm missing something here. Can you guys advise where should I look or what should I fix in order to get this module working? I was living under impression that when I install module via pip in my environment, PyCharm will detect these changes. However, it seems something is broken on my side ...
Open python console of your pyCharm. Click on Rerun. It will say something like following on the very first line
in this scenario pyCharm is using following interpretor
Now fire up console and run following command
This should install your package :)
After pip installing everything I needed. I went to the interpreter and re-pointed it back to where it was at already. My case: python3.6 in /anaconda3/bin/python using virtualenv...
Additionally, before I hit the plus "+" sign to install a new package. I had to deselect the conda icon to the right of it. Seems like it would be the opposite, but only then did it recognize the packages I had/needed via query.
Pycharm is unable to recognize installed local modules, since python interpreter selected is wrong. It should be the one, where your pip packages are installed i.e. virtual environment.
I had installed packages via pip in Windows. In Pycharm, they were neither detected nor any other Python interpreter was being shown (only python 3.6 is installed on my system).
I restarted the IDE. Now I was able to see python interpreter created in my virtual environment. Select that python interpreter and all your packages will be shown and detected. Enjoy!
If you are using PyCharms CE (Community Edition), then click on:
File->Default Settings->Project Interpretor
See the + sign at the bottom, click on it. It will open another dialog with a host of modules available. Select your package (e.g. requests) and PyCharm will do the rest.
MD
Using dual python
2.7
and3.4
with2.7
as default, I've always used pip3 to install modules for the3.4
interpreter, andpip
to install modules for the2.7
interpreter.Try this:
pip3 install requests
In my case, using a pre-existing virtualenv did not work in the editor - all modules were marked as unresolved reference (running naturally works, as this is outside of the editor's config, just running an external process (not so easy for debugging)).
Turns out PyCharm did not add the site-packages directory... the fix is to manually add it.
Open File -> Settings -> Project Interpreter, pick "Show All..." (to edit the config) (1), pick your interpreter (2), and click "Show paths of selected interpreter" (3).
In that screen, manually add the "site-packages" directory of the virtual environment (4) (I've added the "Lib" also, for a good measure); once done and saved, they will turn up in the interpreter paths.
The other thing that won't hurt to do is select "Associate this virtual environment with the current project", in the interpreter's edit box.