conda usage

conda

Basic usage

1. Creation Environment (create a called py36, python version 3.6 environment)

创建的环境在默认路径
conda create -n py36 python=3.6

通过以下方式指定路径
conda create --prefix="/data/envs/my_py_env"  python=3.6.3

2, delete the environment (environmental example for deletion of the name py36)

conda remove -n py36 --all

3, activation environment (examples named activation py36 environment)

conda activate py36

4, exit environment

conda deactivate

5, Tsinghua mirror source download (download examples numpy) significantly improve the download speed ah ah

pip install numpy -i https://pypi.tuna.tsinghua.edu.cn/simple

6, pip / anaconda directly modify the image source, not every increase in the back link

conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/

Software Installation

Which view the current configuration of the environment and the current environment in which

conda env list

View a list of the current environment installation

conda list

View the list of designated installation environment

conda list -n py36

Install new packages

安装到当前环境的软件包
conda install xxx

安装和卸载指定环境的软件包
conda install -n my_py_env package_name
conda uninstall -n my_py_env package_name

Copies of the same platform environment

Directly xx/anaconda3/envs/py36copied to the corresponding target machine anaconda3directory. Activation py36environment

source activate py36

Export Configuration conda environment, then import on the new machine

Ensure that each software version is exactly the same

Export

conda env export > requirements.yml
或
conda list -e > requirements.txt    

Import, if you need to modify the name of the environment, open requirements.yml modify the first and last lines to

conda env create -f requirements.yml
或
conda create -name xyz --file requirements.txt      // 注意和上面导出的方式对应的文件名要一致,文件名和方式要对应

Environmental copy

conda create -n BBB --clone AAA

–clone ENV :Path to (or name of) existing local environment.

-Clone argument behind not only the name of the environment, can also be a path to the environment.

The original directory on the target computer conda environment copied to the new computer, then use:

conda create -n BBB --clone ~/path

View Packages

conda info -e

Note: transplant environment is only installed with the original environment conda installcommand to install packages, loaded with things like pip no transplant, you need to reinstall

Cross-platform export environment

By default, conda use to build export environment, but the building may be platform-specific.

Use --no-build logo:

conda env export --no-build > environment.yml

pip

Export pip environment

pip Export installed library to requirements.txt

pip freeze > requirements.txt

Pip library introduced into the system are listed requirements.txt

pip install -r requirements.txt

Guess you like

Origin www.cnblogs.com/brookin/p/12108758.html