Pycharm configures the corresponding environment for the project (use the command line to create a new environment in Anaconda)

Pycharm configures the corresponding environment for the project (use the command line to create a new environment in Anaconda)

open Anaconda Prompt
insert image description here
input command

命令:conda create -n env_name python=x.x

insert image description here
env_name: virtual environment name xx: python version
The newly created environment is in the path E:\Anaconda3\envs (the path where Anaconda3 is installed)
insert image description here
enter the command to view all environments

conda env list

insert image description here
It is found that there are two environments, one is the base environment, and the other py39 is our newly created environment
Enter the command to activate the py39 environment

conda activate py39

insert image description here
Now, I have used the command to create an py39environment named
(1) Open the project (in this case, only existing projects can be opened, and new projects cannot be created).
The project I opened here is O3

File->setting->New Project->Previously Configured Interpreter->Add

insert image description here
Add the environment
Note: Be sure to clickLoad ENVIRONMENTS
insert image description here
Click OK, return, we found that the interpreter of the project has changed to py39
insert image description here


Summarize:

In general, there are two methods
(1) If you are interested in creating a new environment directly through pycharm, you can read the blogger’s previous blog. Use Pycharm to configure the corresponding environment for the project (create the environment directly in Pycharm) + import the library.
This method can only use python version 3.7 and cannot be changed.
(2) Use the conda command line to create a new environment and import pycharm.
This method can use different versions of python (such as the environment created in this article, the python version is 3.9)

Finish!
Related learning links : [Anaconda creates a new environment and settings in pycharm]

Guess you like

Origin blog.csdn.net/weixin_45913084/article/details/129066589