ModuleNotFoundError: No module named '...'

I am using a System Interpretor and when I install modules, they show up when I enter the Settings >> Project Interpretor menu, and I can import them succesfully outside of PyCharm, but when I call them in PyCharm, I always receive the ModuleNotFoundError. I have checked the paths that are being searched in my interpretor, and they contain and should find all of my modules, but for soem reason they do not. 

4
9 comments
Avatar
Permanently deleted user

I am even able to import the modules succesfully when I am using the Python Console inside of PyCharm

2

Sounds like a similiar issue I have been seeing lately, but since you are working and installing everything in the system it shows up for you more.

I have a project with a virtual environment with a boatload of pypy modules.

What I have noticed recently is that i have to invalidate the cache, restart and then let it reindex it all (be patient, it can take a while if there are loads (under the File menu, Invalidate Caches)

The modules are there, but Pycharm will tell me that it can't find "X" or "X" is not installed sometimes. When it does I HAVE to do the above.

In general, you should set up a venv for each project, which limits that issue for me just to that one project, but it sounds like might be we are having the same issue. Actually, I keep on meaning to check if there is a bug report out.

Edit: Nothing I could find but I suck at Youtrack searching. Next time it happends, I'll try and grab more specifics and then maybe post it.

0

Maybe I have the same problem trying to work with googel API
Its working in command prompt
import the following
from googleapiclient.discovery import build
from google_auth_oauthlib.flow import InstalledAppFlow
from google.auth.transport.requests import Request
with erorr
ModuleNotFoundError: No module named 'googleapiclient'

0

You probably need to install 'googleapiclient' for your interpreter or configure the same interpreter you use in command line.

1

I'm having the same issue... The packages are all installed in my conda enviorment but I get an error when I try importing them.

1

Same, it happens with CLion and PyCharm so far...

1

In Pycharm, I found that I had to:

  1. Install __init__.py at every level
  2. use the . notation:  from .file import Class
0
Avatar
Permanently deleted user

This can result from your project's package/directory name matching a Python built-in, for example `test` (try `tests` instead).

The interesting thing was that from a terminal with `PYTHONPATH` set to the project directory, it imported fine, yet PyCharm's Python Console raised an exception. 

0

Please sign in to leave a comment.