Pycharm configures the corresponding environment for the project (use the command line to create a new environment in Anaconda)
open Anaconda Prompt
input command
命令:conda create -n env_name python=x.x
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)
enter the command to view all environments
conda env list
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
Now, I have used the command to create an py39
environment 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
Add the environment
Note: Be sure to clickLoad ENVIRONMENTS
Click OK, return, we found that the interpreter of the project has changed to py39
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]