PyCharm does not recognize installed module

I'm having trouble using the Queries module on my Mac. I am using python34 and I installed the "request" module via pip. I can verify this by completing the installation again and it will show me that the 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 the “queries” module through the Python interactive interpreter, trying to execute “import queries” in PyCharm, I get a “Without query module” error. I checked the PyCharm Python interpreter settings and (I suppose) it installed on the same python34 as in my environment. However, I cannot see the "request" module specified in PyCharm.

PyCharm Python interpreter settings

Obviously, I missed something. Can you guys advise where I should look, or what should I fix to make this module work? My impression is that when I install the module through pip in my environment, PyCharm will detect these changes. However, it seems that something has broken on my side ...

+17
source share
9 answers

If you are using PyCharms CE (Community Edition), click the button:

File->Default Settings->Project Interpretor

Screenshot: Interpreter Settings

See the "+" sign below, click on it. It will open another dialog with many available modules. Choose your package (for example, requests), and PyCharm will do the rest.

MD

+23
source

Open the python console of your pyCharm. Click Retry. The first line will say the following:

 /System/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7 /Applications/PyCharm.app/Contents/helpers/pydev/pydevconsole.py 52631 52632 

in this case pyCharm uses the following interpreter

 /System/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7 

Now start the console and run the following command

 sudo /System/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7 -m pip install <name of the package> 

This should install your package :)

+7
source

Using dual python 2.7 and 3.4 with 2.7 by default, I always used pip3 to install modules for the interpreter 3.4 and pip to install modules for the interpreter 2.7 .

Try the following:

pip3 install requests

+5
source

In my case, the use of the pre-existing virtualenv did not work in the editor - all modules were marked as unresolved links (a natural start works, since this happens outside the editor’s configuration, an external process is simply executed (it’s not so easy to debug)).
Turns out PyCharm didn't add the site-packages directory ... the fix is ​​to add it manually.

Open File → Settings → Project Interpreter, select "Show All ..." (to edit the configuration) (1), select your interpreter (2) and click "Show Paths of the Selected Translator" (3).

On this screen, manually add the "site-packages" directory of the virtual environment (4) (I also added that "Lib", for good measure); After everything is done and saved, they will appear in the paths of the interpreter.

the steps

Another that would do well is to select “Link this virtual environment to the current project” in the interpreter editing field.

+4
source

Pycharm cannot recognize installed local modules because the selected python interpreter is wrong. It should be the one where your package packages are installed, i.e. a virtual environment.

I installed packages through pip on Windows. They were not detected in Pycharm, and no Python interpreter showed up (only python 3.6 is installed on my system).

enter image description here

I restarted the IDE. Now I was able to see the python interpreter created in my virtual environment. Select this python interpreter and all your packages will be shown and discovered. Enjoy it!

enter image description here

+3
source

After installing the pip, all I need. I went to the translator and returned him to where he was already. My case: python3.6 in / anaconda3 / bin / python using virtualenv ...

Also, before I click the “+” sign to install a new package. I had to deselect the Conda icon to the right of it. It seems that everything will be the other way around, but only then did he recognize the packages that I had / needed through the request.

0
source
  1. If you go to the pycharm project → pycharm on one of the installed packages, then move the mouse cursor → you will see where pycharm installs the packages. This is where you should have the package installed.

  2. Now, if you did sudo -H pip3 install <package> pip3 will install it in another directory, which is located in /usr/local/lib/site-packages

since this is a directory other than what pycharm knows, your package does not appear in pycharm .

Solution: just install the package using pycharm by going to File-> Settings → Project-> Project Interpreter → click (+) and find the package you want to install and just click OK.

→ You will be prompted to install the package successfully, and you will see its pycharm .

0
source

In my case, the packages were installed using setup.py + easy_install, and they fall into the * .egg directories in the site_package directory, which python can recognize, but not pycharm.

I deleted them all and then reinstalled using pip install, and after that everything worked, fortunately, the project I was working on created a require.txt file, so the command for it was:

pip install -r./requirement.txt

0
source

This is due to the fact that you did not choose two options when creating a project: - ** inherit packages of the global site ** make available for all projects Now you need to create a new project and do not forget to mark these two options when choosing a project interpreter,

0
source

All Articles