1. Conda virtual environment
First of all, try not to install your own package directly in the base. There are two reasons:
1. The base environment is the basis for conda to run, and it cannot be cleared with one click. If the base environment is damaged, either roll back or uninstall and reinstall, which is troublesome
2. Many packages in base are not required by the project, which can easily lead to bloated projects when packaging
The following operations are performed in the conda console
1. Create an environment
conda create -n 变量文件 python=版本号
2. Activate/exit the environment
activate 环境名
conda deactivate
3. Print environment list
conda env list
4. Remove the environment
conda deactivate #如果在环境中需要先退出环境
conda remove -n 需要删除的环境名 --all
It should be noted that this cannot be used for the base environment. If you want to restore the base, you can try to roll back or uninstall directly
conda install --revision 0 #base环境滚回
Second, the environment is added to the system variables
This problem manifests itself in the inability to use various conda commands (including pip, etc.) in the consoles in vscode and pycharm. It is generally caused by not checking " add conda to system PATH " during installation.
It is best to check this when installing, but it doesn't matter if it is already installed. Just add the following three paths to system PATH.
Note that ... in the path is your own conda installation path. It doesn’t matter if you forget the conda installation path. Use: conda env list in the console to find the path where the environment is located.
C:\...\Anaconda3
C:\...\Anaconda3\Scripts
C:\..\Anaconda3\Library\bin
The entry path of system PATH is: Settings -> System Information -> Advanced System Settings -> Environment Variables
Find PATH in the system variable below , double-click to enter, click New , copy the above 3 paths into it and save it.
After completing the above operations, restart vscode or pycharm to use the conda statement in the built-in console.