Anaconda views, creates, manages, and uses python environments
Since different projects require different python versions, we use Anaconda for version management. Here is a record of our experience:
Once you have downloaded and installed Anaconda from the official website (very simple, I won’t go into details here) :
1. View the Python environment
conda info --env
Copy the code
You can see all Python environments preceded by an ‘*’ to represent the current environment:
2. Create the Python environment
Conda create --name python37 python=3.7Copy the code
Python3.7 means to create a python3.7 environment, which we will name python37
Message after successful installation:
Now let’s use it again
conda info --env
Copy the code
Look at the environment:
There it is. It was created successfully. Nothing wrong with it.
3. Manage and use the Python environment
use
conda activate python37
Copy the code
To activate the environment you just created:
Try to use
pip install numpy
Copy the code
To install a common package for this environment:
Of course you can use it
conda install numpy
Copy the code
To install, but many related packages will be installed at the same time, which will not be demonstrated here.
Use deactivate to deactivate an environment
deactivate python37
Copy the code
4. View the anaconda installation path
Conda info –env has the same physical path as conda info –env:
5. Delete the Conda environment
After that we delete python37:
conda remove -n python37 --all
Copy the code
Look at the folder again, sure enough, it has been deleted:
6. Copy/clone an environment
To clone an environment, here a copy called my_PYTHon37 will be created by cloning PYTHon37:
conda create -n my_python37 --clone python37
Copy the code
7. By changing the Conda source, you can greatly improve the download speed of some packages
Many of you may experience slow download speeds when installing python because, wall, wall, wall. Modifying the source solves this problem
To modify the source, type the following two commands:
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --set show_channel_urls yes
Copy the code
Change conda back to the default source
Sometimes, if for some reason, the image can not be uploaded and you need to switch back to the default source of conda, just type in the command line:
conda config --remove-key channels
Copy the code
Temporary changes to PIP source to improve download speed (use Tsinghua source to speed up installation)
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple xxxx
Copy the code
This will be from tsinghua side of the mirror to install XXXX library
8. Where is the path to the python executor?
~ / anaconda2 / envs path contains all of you to create a virtual environment, environment py37 python actuators in ~ / anaconda2 / envs/py37 / bin/python path, Pycharm needs to know this path when remote calls the remote compiler.