当前位置:网站首页>[work direction] CONDA common command summary

[work direction] CONDA common command summary

2022-06-09 07:00:00 shuaixio

1. conda Introduce
  • conda Is in linux、windows and macOS Open source software running on Package management Systems and Environmental management System

  • Package management and environmental management :conda Can be installed quickly 、 Run and update packages and their dependencies ;conda Environment is a directory containing all installation packages and dependencies , Different environments are independent of each other

2. conda and anaconda/miniconda/pip The relationship between
  • anaconda With pre-installed conda、python And many of the packages And scientific computing tools ,conda yes anaconda default python Package and environmental management tools ;

  • miniconda Contains only conda and python And necessary dependencies , yes anaconda A lightweight alternative to

  • conda It can be installed separately Do not rely on anaconda/miniconda Whether to install ,conda Focus on environment and package management

  • stay ~/anaconda/envs I can see conda New virtual environment

  • conda Have both pip Package management capabilities , It also has vitualenv Environmental management functions , So functionally conda It can be seen as pip and vitualenv The combination of ;

  • pip install python software package , and conda Install package , This may include software written in any language

    anaconda: conda + python + third-party sw
    miniconda: conda + python
    conda: packages + virtual envirenments
    pip: python packages
    
3. conda Common commands
3.1 Version information
  • View version information

    conda --version		# conda -V
    
  • to update conda edition

    conda update conda
    
3.2 Environmental management
  • See all environments

    conda info --env	# conda info -e
    
  • Start the virtual environment

    conda activate env_name		# conda activate The default entry is conda base Based on the environment 
    
  • Exit virtual environment

    conda deactivate	#  or conda deactivate env_name
    
  • Creating a virtual environment , Install the software package at the same time , Version can be specified

    conda create --name virtual_env_name python=3.8 numpy scipy
    
  • according to requirements.txt Creating a virtual environment

    conda create --name virtual_env_name --file requirements.txt
    

    requirements.txt give an example

    # This file may be used to create an environment using:
    # conda create --name env_name --file requirements.txt -c pytorch
    # platform: linux-64
    cudatoolkit=10.2.89
    numpy=1.19.2
    python=3.8.8
    pytorch=1.8.0
    tensorboard=2.4.1
    
  • export requirements.txt file

    conda list -e > requirements.txt	#  or  --export
    
  • Copy an environment

    conda create --name new_env_name --clone old_env_name 
    
  • Delete an environment

    conda remove --name your_env_name --all
    
3.3 Package management
  • View the installed packages in the current environment

    conda list
    
  • Find the available versions of the package

    conda search beautifulsoup4
    conda search --full-name python
    
  • Install package

    conda install package_name
    
    conda install -c channel_name package_name	#  Install the package from the specified library  -c for --channel
    conda install -c conda-forge bottleneck		#  install bottleneck
    

    conda If it cannot be installed, it can be used pip Carry out the installation such as pip install numpy

  • Install local package

    conda install --use-local  ~/Downloads/a.tar.bz2
    
  • Remove package

    conda uninstall package_name	#  Unload a package 
    conda remove package_name		# uninstall Another name for alias 
    
  • Uninstall the package in the specified environment

    conda remove --name env_name package
    
  • Use requirements.txt Mass installation packages

    conda install --yes --file requirements.txt
    
  • Add : Use in a specific virtual environment conda install/pip install The installed packages are only in the current environment


Reference article :
conda What is it? conda and pip The difference between
requirements.txt Batch processing
conda install and pip install The difference between
conda install -c
conda Brief introduction
requirements.txt Use

created by shuaixio, 2022.06.03

原网站

版权声明
本文为[shuaixio]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/160/202206090649466240.html