Import anaconda installed libraries and packages in pycharm

Use software version:

pycharm 2020.3.2 Professional Edition

anaconda3 5.2.0 

 

The thing is like this:

I changed my computer and installed anaconda and pycharm. In order to learn pytorch, I used anaconda to create an environment called pytorch (path is D:\Users\xf\Anaconda3\envs\code\pytorch) , and some commonly used packages Such as numpy, scipy, pytorch, etc. have been installed and configured

Then today I want to debug the serial communication of Jetson nano, so I installed the pyserial package (installed in anaconda)

After downloading the demo, I opened the code but it prompts "No module named serial", so I started to find the reason. (I thought it was a big problem at the time, but later found out that I was stupid...)

the reason:

It is because of the wrong choice of python interpreter in the settings!

First open pycharm, select "File->settings...->Python Interpreter", and found that my Python Interpreter defaults to python.exe under code

And I installed the commonly used packages in the pytorch environment, so I should choose python.exe under pytorch.

Proceed as follows:

Click the small gear to the right of Python Interpreter

Select "Add"

Find the "Conda Environment" option in the left tab and select it, then select "Existing environment", first check whether "Interpreter" is using python.exe in the environment, if it is, click OK

If not, just select "New environment" and add it.

It can be used! (It's so simple, I didn't even notice it, I cried stupidly...)

Guess you like

Origin blog.csdn.net/ting_qifengl/article/details/113665135