2

If I do something like "import selenium" (or any other kind of third party library) in a .py file and then run it from the terminal, it works just fine. But if I make a new file in PyCharm CE and do the same thing, it can't find the library / module.

How can I fix this or get it to point in the right location? I use a Macbook Pro.

user6419910
  • 155
  • 2
  • 12

2 Answers2

5

You need to setup your project in PyCharm to use the Python interpreter that has your libraries:

Go to: file->settings->project->project interpreter

And select the appropriate interpreter from the dropdown. After selecting an interpreter, the window displays a list of libraries installed on that interpreter; this should further help you make the right selection.

Moses Koledoye
  • 77,341
  • 8
  • 133
  • 139
2

I've faced a similar issue on Pop!_OS after installing PyCharm via Flatpak. I think the installation is somehow incomplete, as I've had these issues (among others):

  • Installer could not create the menu shortcut due to the lack of credentials. Unlike during a typical installation, it wouldn't ask for the password and instead I had to uncheck that option altogether.
  • Built-in terminal defaulted to sh. Even after changing to bash, it would not read my .bashrc and many commands were missing.
  • After changing the interpreter into a local virtualenv, it would just default to Python 3.7 (even though the version was actually 3.8) and it didn't see any of my installed libraries.
  • When I've tried to use a Docker Compose environment, IDE failed to detect Docker Compose installation.

I've eventually uninstalled PyCharm and downloaded it directly from Jetbrains website to make it work correctly.

Czyzby
  • 2,999
  • 1
  • 22
  • 40