Python: After using pip to install the module, Pycharm imports an error

I encountered several times that I installed the module with pip on the command line, but still reported an error in pycharm and asked me to install the package.

It is because pycharm creates a virtual working environment for each project when it creates a project. It is equivalent to separating each project, and the python interpreter and library used are all in their own project folder.

 It is found that the python interpreter and software package used by the new project can only be in its own folder

 But the python interpreter and various modules installed with pip are not in these project folders, so the project cannot be used.

And in this way, the software package installed in this project cannot be used in other projects, and needs to be installed again

Solution:

Just change the python interpreter used to the system interpreter (that is, install it yourself).

ps:

The python.exe path I installed is: D:\python\python37\python.exe

The python path used by the virtual environment of the pycharm project is: D:\python\pythonProject2\venv\Scripts\python.exe

Click Edit Range -> 

Project->Python Interpreter->Add Interpreter->Add Local Interpreter (If you have changed it, you can directly find it in the small triangle)

What is shown here is the python interpreter and software package used in the working environment of the project. It can be found that there is no library that I have installed with pip

 

-> System Interpreter -> Find the python.exe you installed and select and confirm

 

This shows all the packages I installed using pip

 

Guess you like

Origin blog.csdn.net/weixin_53306046/article/details/127857149