conda environment in the server


conda activate pytorch1.12_gpu
(X)conda install sklearn
(√)conda install scikit-learn

write on top

Using the full-featured anaconda, you can use conda to control the same package environment, and install py27 and py35 versions at the same time.

Recently, I often use the conda of the server, and summarize the commands for easy calling

Reference: https://blog.csdn.net/Tianweidadada/article/details/80150056
https://blog.csdn.net/weixin_41466947/article/details/107377071

Conda environment configuration

View the environment under the current system:

conda info -e

Create a new environment:

# 指定python版本为3.8,注意至少需要指定python版本或者要安装的包# 后一种情况下,自动安装最新python版本
conda create -n env_name python=3.8
# 同时安装必要的包
conda create -n env_name numpy matplotlib python=2.7

Enter the virtual environment:

conda activate pytorch1.12_gpu

Exit the virtual environment:

conda deactivate

context switching

# 切换到新环境# linux/Mac下需要使用source activate env_name
activate env_name

Exit the environment, you can also activate rootswitch back to the root environment

deactivate env_name

Addition, deletion, modification and query of the environment

Check out the virtual environment:

conda env list

conda clone environment

conda create --name B --clone A

conda delete environment

conda remove --name B --all
conda remove -n env_name --all

conda rename environment

conda create --name B --clone A
conda remove --name A --all

package management

There are two options for installing a package in a specific environment, one is to switch to the environment for direct installation, and the other is to specify the environment parameter -n during installation

activate env_nameconda install pandas
# 安装anaconda发行版中所有的包
conda install anaconda
conda install -n env_name pandas

View installed packages

conda list
# 指定查看某环境下安装的package
conda list -n env_name

find package

conda search pyqtgraph

update package

conda update numpy
conda update anaconda

uninstall package

conda remove numpy

Set up domestic mirroring

restore default sources

conda config --remove-key channels

Change the source of anaconda (join Tsinghua source)

vi ~/.condarc

Changing https in channels to http
is the reason for network security. The https protocol is a secure ssl encrypted transmission protocol, which is the communication encryption between the browser and the server, so as to ensure the security of transmission.

auto_activate_base: false
channels:
  - http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch
  - http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
  - http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
  - defaults
show_channel_urls: true
default_channels:
  - http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
  - http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
  - http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r
custom_channels:
  conda-forge: http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  msys2: http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  bioconda: http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  menpo: http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  pytorch: http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  simpleitk: http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud

clear cache

In order to ensure that the index provided by the mirror site is used, clear the index cache, enter:

conda clean -i 

After getting the command according to different requirements, you need to remove -c pytorch before going to the mirror source you added to download

pycharm package update

The easiest way, after installing pip, click the python interpreter in the status bar in the lower right corner, click the current python interpreter again, this will trigger the rebuilding of the index, and the remote package will be downloaded to the local

Guess you like

Origin blog.csdn.net/wtyuong/article/details/128160387