Pan DA
Pan DA

Reputation: 37

Pycharm cann't find the packages or modules installed with pip on windows

Pycharm doesn't sync with the pip packages though i have added the path in environment variable. The following elements will clear the topic:

already installed sklearn package: enter image description here

pycharm can't find that package:

enter image description here

environment variable:

https://i.sstatic.net/1zehq.png

Upvotes: 2

Views: 16352

Answers (4)

harbun
harbun

Reputation: 525

If you did not "inherit global-site packages" upon creating the project, check in the project tree under External Libaries, if the folder is marked in red. I.e. if you do not use the systems default interpreter , Lib/site-packages could be marked in red. To add those libraries afterwards, go to: File-Project(your project)\Project Structure, select +Add Content Root, browse to site-packages (or the respective folder you want to add), and add it. After clicking OK the folder will not be marked red any longer. (tested in PyCharm 2020.3)

Upvotes: 3

GetHacked
GetHacked

Reputation: 554

Seems like the interpreter selected isn't where you think it is. If you're using a different interpreter than the system's default, it won't load the modules. To add the modules in PyCharm, go to your Settings, Project Interpreter, the Add Button, and install it with PyCharm's integrated package management.

steps

Upvotes: 2

Nipun Thennakoon
Nipun Thennakoon

Reputation: 3734

The thing is that pycharm creates all of your projects inside a virtual environment. So the packages that you installed outside the virtual environment(global site packages) does not get inherited in to your project. There is a simple solution for that. When you create a pycharm project, make sure to check the "inherit global-site packages" checkbox as shown here.Then you'll be able to import all the packages to your virtual environment, provided they have been installed in your computer.

enter image description here

Alternatively you can install all the packages separately using "pip install" in the pycharm terminal. If the package has been installed outside the virtual environment, pip will use cached files instead of downloading the package again.

Or you can install the packages using Settings -> Project -> Project Interpreter as the other answers suggests.

Upvotes: 4

Enzo Romano
Enzo Romano

Reputation: 177

In PyCharm, go to File / Default Settings / Project Interpreter

On that page there is a plus in the bottom left, whatever modules you have installed through pip you may need to manually install there. Or you can change your project interpreter to make sure you are using the correct interpreter with all your installed modules.

Upvotes: 2

Related Questions