What is the difference between pip and conda, and what are the common commands?

What is the difference between pip and conda, and what are the common commands?

1. pip and conda

  • pip is a Python package management tool that provides functions for finding, downloading, installing, and uninstalling Python packages
  • Conda is an open source package management system and environment management system that runs on Windows, macOS, and Linux. Conda quickly installs, runs, and updates packages and their dependencies. Conda makes it easy to create, save, load, and switch environments on your local computer. It was created for Python programs, but it can package and distribute software in any language ( Python, R, Ruby, Lua, Scala, Java, JavaScript, C/C++, FORTRAN, etc. )
  • conda is a more powerful management tool than pip
    • support different languages
    • Support creating different environments and managing packages in different environments

2. pip common commands

  • show version and path

    • pip --version
      
  • get help

    • pip --help
      
  • Installation package

    • pip install PackageName				#最新版本
      pip install PackageName==version(2.0.0)		#指定版本
      pip install "PackageName>=version(2.0.0)"	#最小版本
      pip install -i https://pypi.tuna.tsinghua.edu.cn/simple PackageName #安装指定镜像源的包
      
  • upgrade package

    • pip install --upgrade PackageName
      
  • uninstall package

    • pip uninstall PackageName
      
  • search package

    • pip search PackageName
      
  • Display package information

    • pip show PackageName
      
  • Display information about the installation package and its files

    • pip show -f PackageName
      
  • Show a list of installed packages

    • pip list
      
  • show upgradable packages

    • pip list -o
      

3. Conda common commands

  • show version

    • conda --version
      conda -V
      
  • get help

    • conda --help
      conda -h
      

      Get help for a command

    • conda remove --help
      
  • environmental management

    • View command help for environment management

      • conda env -h
        
    • create environment

      • conda create --name envName
        
    • Create an environment with a specified python version

      • conda create --name envName pyhon=3.7
        
    • Display the list of currently created environments

      • conda env list
        
    • enter an environment

      • conda activate envName
        
    • exit the current environment

      • conda deactivate
        
    • copy an environment

      • conda create --name newEnvName --clone oleEnvName
        
    • delete an environment

      • conda remove --name envName --all
        
    • Migration environment

      • export environment

        • # 先进入要迁移的环境
          conda env export > environment.yml
          
      • reproduce the environment

        • conda env create -f environment.yml
          
      • Export packages in the environment

        • # 先进入要导出的环境
          conda list -e > requirements.txt
          
      • Install the package in requirements

        • conda install --yes --file requirements.txt
          

      The above export is only the package in the conda environment. If you use the package in the pip manager, you can do the following

      • export

        • pip freeze > requirements.txt
          
      • Install

        • pip install -r requirements.txt
          遇到错误中断,使用如下命令
          while read requirement; do  pip install $requirement; done < requirements.txt
          
  • package management

    • Display the package list under the current environment (default is base)

      • conda list
        
    • Display a list of packages not in the current environment

      • conda list -n envName
        
    • Installation package

      • conda install packageName
        
    • Install packages for specific environments

      • conda install -n envName packageName
        
    • uninstall package

      • conda uninstall packageName
        
    • Uninstall the installation package for the specified environment

      • conda uninstall -n envName packageName
        

Guess you like

Origin blog.csdn.net/eastking0530/article/details/126571514