Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Module not found error in PyCharm , but it is installed as Anaconda package

I have installed Anaconda 3 and PyCharm CE after that. I am able to chose the interpreter to be Conda environment. But when I try using certain packages such as matplotlib it throws "Module not found error". When I run pip it returns saying that matplotlib is available.

pip install matplotlib
Requirement already satisfied: matplotlib in./anaconda3/lib/python3.6/site-packages

Clearly the package is there and for some reason it does not show up.

like image 988
Ash Avatar asked Mar 04 '18 16:03

Ash


People also ask

Why PyCharm Cannot import module?

Troubleshooting: Try installing/importing a package from the system terminal (outside of PyCharm) using the same interpreter/environment. In case you are using a virtualenv/conda environment as your Project Interpreter in PyCharm, it is enough to activate that environment in the system terminal and then do the test.

Can I have both Anaconda and PyCharm?

They work together fine - you just need to set up a run configuration that points to the Anaconda installation. Show activity on this post. My experience with Anaconda was using it for a machine learning learning class. We used jupyter notebook to do all our learning and projects.


2 Answers

Apparently the naming of the selection depends on the operating system, but the Python interpreter can be selected as follows:

  • File > Preferences > Project > Python Interpreter (MacOS)
  • File > Settings > Project > Python Interpreter (Windows, Linux)

Using the dropdown select the right Python interpreter. Depending on your OS and setup this can be the default interpreter (e.g. ~/anaconda3/bin/python) or the interpreter corresponding to the Conda environment of your choice (e.g. C:\users\username\.conda\envs\projectname\python.exe).

screenshot of PyCharm Settings

Now all the packages installed with Anaconda should be listed.

screenshot of PyCharm Preferences listing packages installed

like image 170
Ash Avatar answered Sep 16 '22 14:09

Ash


With Python 2019.2.3 (CE) there are the following steps on a Windows 10 system:

  1. Go to File --> Settings in the menu bar or alternatively press Ctrl+Alt+S
  2. Go to to the entry Project --> Project Interpreter

    Step 1
  3. Select Show All in the dropdown menu:

Step 2

  1. if your Conda Environment is not listed, press the + button and select Conda Environment on the left:

    Step 3

Now select the desired environment by opening the dropdown menu Interpreter and click OK. Now your conda environment should be listed as project interpreter. Click OK to close the window and click Apply in the settings window.

like image 37
Douy789 Avatar answered Sep 16 '22 14:09

Douy789