How to activate conda environment? In response to this problem, this tutorial will teach you how to create a new environment with conda in three steps: creating, activating, and viewing the active environment.
How to activate the conda environment
Step 1: Create
conda create --name yourEnv python=2.7
–name: It can also be abbreviated as [-n], and [yourEnv] is the name of the newly created virtual environment. After creation, you can find the envs/yourEnv directory in the directory where anaconda is installed
python=2.7: is the version number of python. It can also be specified as [python=3.6]. If not specified, the default is the version of python when anaconda is installed.
If you want to install some python packages while creating the environment:
conda create -n yourEnv python=3.6 numpy pandas
Step 2: Activate
windows ==> activate yourEnv
linux/mac ==> source activate yourEnv
tips:
Linux users may need to enter the anaconda/envs directory to activate the required environment;
If linux users do not want to go to the directory to activate every time, they need to set the global environment variable, and add the bin file under the path to be activated to the global environment variable. like
Add /home/yourName/anaconda3/envs/yourEnv/bin to ~/.bash_profile.
Add to the windows user environment variable (change to your own path):
D:\Anaconda3
D:\Anaconda3\Scripts
D:\Anaconda3\Library\bin
Step 3: View Active Environments
conda info --envs: The one with [*] in the output is the current environment
conda some commands
conda list: see the packages and versions installed in this environment
conda install numpy scikit-learn: install numpy sklearn package
conda env remove -n yourEnv: delete your environment
conda env list: View all environments
anaconda download
Compared with the official website, it is recommended to download the corresponding version from the Tsinghua Open Source Mirror Station
wget https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/Anaconda3-5.3.1-Linux-x86_64.sh
bash Anaconda3-5.3.1-Linux-x86_64.sh
Tsinghua mirror source configuration
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
conda config --set show_channel_urls yes
Remotely:
Jupyter notebook remote access server
Reference: Jupyter notebook remote access server
Pay attention to the first person's comment: "I need to modify c.NotebookApp.ip='0.0.0.0' to use"
And according to my version c.IPKernelApp.pylab = 'inline' will report an error
The way of sshkey connection:
Pycharm connects to the server remotely
ctrl+s can't upload automatically. It may be that the default server is not selected. You can configure it under tools --> deployment -->configuration
Other notes:
pytorch installation failed
Remember to add Tsinghua pytorch image:
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/
for legacy win-64
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/peterjc123/
If it is still unsuccessful, remove the -c pytorch from the official installation command conda install pytorch torchvision cudatoolkit=10.0 -c pytorch and change it to conda install pytorch
torchvision cudatoolkit=10.0
The above is the step-by-step tutorial for creating a new environment with conda. I believe that everyone has already solved the simple problem of "how to activate the conda environment" after seeing this.