current position:Home>Explain Python CONDA in detail
Explain Python CONDA in detail
2022-05-15 04:27:25【The way of Python data】
source :pythonic Biological man
This article continues to introduce Anaconda Of Strong housekeeper Conda: can Flexible management python My bag package And the environment environment.
Conda brief introduction
Packages for multiple programming languages package And virtual environments environment Management of ;
Very simple to complete package Installation 、 function 、 to update 、 Delete 、 Dependence problem ;
operational repo.anaconda.com On 7,500+ packages ;
Very simple to complete the construction of different environments 、 preservation 、 Loading and switching ;
Support language 【 This article only introduces python operation 】:Python、R、Ruby、Lua、Scala、Java、JavaScript、C / C ++、FORTRAN;
Support operating system :Windows, macOS and Linux.
Contents of this article
1、 Download source channel Detailed explanation
The domestic part is easy to use conda Download source
Tsinghua University source
University of science and technology of China
The domestic part is easy to use pip Download source
pip Source usage
To configure conda Download source
Method 1
Method 2
View the configured download source
View the configured download source priority
Delete download source
Method 1
Method 2
2、conda System related commands
Query a conda Command help documentation 【 The most useful command 】
see conda System version and other information
see conda All configuration information
conda Version update
Anaconda Update all packages in
conda to update python
3、 package package management
see 【 The current environment 】 All packages installed
see 【 The current environment 】 already installed 【 Specified package 】 Information
see 【 Specify the environment 】 Installed package information
View the available versions of the package
View a range of version packages
Install the latest version of package
Specify the version pack installation
Appoint list Medium version package installation
Install the package in the specified range
Package installation skipped 【y/n】
Install the package into the specified environment
Current environment package update
Specify the environment package update
Package uninstall
4、 Environmental Science environment management
View the existing environment
Create an environment
Environment activation
Environment exit
Environmental cloning
Environment delete
5、Conda、pip And virtualenv Three more
1、 Download source channel Detailed explanation
Download source , That is, the website where you download things ;
because Anaconda Our server is abroad , The default source is Anaconda.org, Downloading corresponding resources in China is slow , Therefore, it is necessary to set up domestic Anaconda Mirror source .
The domestic part is easy to use conda Download source
Tsinghua University source
website :https://mirror.tuna.tsinghua.edu.cn/help/anaconda/
# Tsinghua University source
https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/
University of science and technology of China
website :https://mirrors.ustc.edu.cn/
# University of science and technology of China
https://mirrors.ustc.edu.cn/anaconda/pkgs/main/
https://mirrors.ustc.edu.cn/anaconda/pkgs/free/
https://mirrors.ustc.edu.cn/anaconda/cloud/conda-forge/
The domestic part is easy to use pip Download source
# Tsinghua University source
https://pypi.tuna.tsinghua.edu.cn/simple
# China University of science and technology
https://pypi.mirrors.ustc.edu.cn/simple/
# Douban source
https://pypi.doubanio.com/simple
pip Source usage
pip install pandas -i https://pypi.tuna.tsinghua.edu.cn/simple# Download using Tsinghua source pandas package
To configure conda Download source
Method 1
Take the configuration of Tsinghua University source as an example .
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
conda config --set show_channel_urls yes The function of is to display the installation source of the package , as follows
Method 2
linux Open down /home/xx/.condarc file , Add the following content and save it
channels:
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
- defaults
show_channel_urls: true
windows Default to none .condarc file , need conda config --set show_channel_urls yes Mr Into , Then add the above content .
View the configured download source
conda config --show channels

View the configured download source priority
conda config --get channels
The default source priority has been reduced to the lowest , The newly added Tsinghua source has the highest priority
Delete download source
Method 1
Delete directly .condarc file
Method 2
conda config --remove channels channels_Name
conda config --remove channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --remove channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
2、conda System related commands
Query a conda Command help documentation 【 The most useful command 】
conda config -h

see conda System version and other information
conda info

see conda All configuration information
conda config --show
The following sections are listed
conda Version update
take conda Update to the latest version
conda update -n base conda
Anaconda Update all packages in
conda update anaconda
conda to update python
to update python To the latest version of the current series , At present, it is python2, Can only be updated to python2 The highest version in , Instead of updating to python3.
conda update python
3、 package package management
see 【 The current environment 】 All packages installed
conda list
Output four columns ,Name( Package name )、Version( Package version number )、Build( Package Creator )、Channel( Package download source ).
see 【 The current environment 】 already installed 【 Specified package 】 Information
conda list PACKAGE_NAME
see 【 Specify the environment 】 Installed package information
conda list -n ENV_NAME
conda list -n python2.7# Look at the environment python2.7 All packages installed under
View the available versions of the package
conda search PACKAGE_NAME
conda search pandas# With pandas For example

View a range of version packages
conda search "PKGNAME [version='>=1.0.0,<1.1']"
conda search "pandas [version='>=1.0.0,<1.1']"# The search version is in 1.0.0 And 1.1 Between pandas
Install the latest version of package
conda install PACKAGE_NAME It is installed in the currently active environment by default , Install the latest version
conda install pandas# Install the latest version by default
Specify the version pack installation
conda install PACKAGE_NAME=VETSION_CODE
conda install pandas=1.1.1# install 1.1.1 Version of pandas
Appoint list Medium version package installation
conda install "PACKAGE_NAME[version='1.0.4 |1.1.1']"
conda install "pandas[version='1.0.4 |1.1.1']"# install pandas 1.0.4 Version or 1.1.1 edition
Install the package in the specified range
conda install "PACKAGE_NAME>1.0.4,<1.1.1"
conda install "pandas>1.0.4,<1.1.1"# The installed version is in 1.0.4 To 1.1.1 Between pandas
Package installation skipped 【y/n】
conda config --set always_yes yes
By default conda config --set always_yes false, In other words, the installation process will ask whether to continue the installation , Set to yes No more pop-up requests . Install the package into the specified environment
conda install -n ENV_NAME PACKAGE_NAME
You can do this , But it's not necessary at all , It is recommended to activate the environment to be installed first , And then install it
conda install -n python2.7 pandas# take pandas Installed in the environment python2.7 in
Current environment package update
conda update PACKAGE_NAME
conda update pandas
Specify the environment package update
conda update -n ENV_NAME PACKAGE_NAME
Package uninstall
conda remove/uninstall PACKAGE_NAMEremove and uninstall Fine
conda remove pandas
4、 Environmental Science environment management
View the existing environment
The following three methods can .
conda info -e
conda info --envs
conda env list

Create an environment
conda create --name ENVNAME python=3.6
conda create -y -n python2.7 python=2.7.7
-y#-y, --yes Do not ask for confirmation. That is, the installation process does not need to enter y confirm
-n python2.7# Set the environment name to python2.7
python=2.7.7# The version of the environment is python=2.7.7, It can be done by conda search python Retrieve the installable version number
The following indicates that it has been created successfully .conda info -e View all current conda Create an environment

Environment activation
conda activate python2.7
At this point, the environment becomes Python2.7
Be careful 1
conda 4.6 Later version , Activate environment Use conda activate
conda 4.6 Previous version , Activate environment Use :
Windows: activate
Linux and macOS: source activate
Environment exit
conda deactivate
Back to the default environment
Environmental cloning
Copy an environment , The two configurations are the same , But it can operate independently
conda create --clone python2.7 --name new_python2.7# The environment python2.7 Clone a new_python2.7

Environment delete
conda remove --name new_python2.7 --all# The environment new_python2.7 Delete

5、Conda、pip And virtualenv Three more
conda Can be managed at the same time python Package and environment ;
pip Only management packs ;
virtualenv Can only manage the environment :https://www.liaoxuefeng.com/wiki/1016959663602400/1019273143120480
Task | conda Simultaneous management package and environment | pip management package | Virtualenv management environment |
---|---|---|---|
package install | conda install $PACKAGE_NAME | pip install $PACKAGE_NAME | X |
package to update | conda update --name $ENVIRONMENT_NAME $PACKAGE_NAME | pip install --upgrade $PACKAGE_NAME | X |
conda to update | conda update conda | Linux/macOS: pip install -U pip Win: python -m pip install -U pip | X |
package uninstall | conda remove --name $ENVIRONMENT_NAME $PACKAGE_NAME | pip uninstall $PACKAGE_NAME | X |
Create a new environment | conda create --name $ENVIRONMENT_NAME python | X | cd $ENV_BASE_DIR; virtualenv $ENVIRONMENT_NAME |
Activate environment | conda activate $ENVIRONMENT_NAME * | X | source $ENV_BASE_DIR/$ENVIRONMENT_NAME/bin/activate |
sign out environment | conda deactivate | X | deactivate |
Search available packages | conda search $SEARCH_TERM | pip search $SEARCH_TERM | X |
Download... From the specified source package | conda install --channel $URL $PACKAGE_NAME | pip install --index-url $URL $PACKAGE_NAME | X |
View installed packages | conda list --name $ENVIRONMENT_NAME | pip list | X |
establish project Requirements document | conda list --export | pip freeze | X |
List all environments | conda info --envs | X | Install virtualenv wrapper, then lsvirtualenv |
conda and pip Mutual installation | conda install pip | pip install conda | X |
Install the specified version Python | conda install python=x.x | X | X |
Python upgrade | conda update python * | X | X |
Reference material
https://github.com/conda/conda
https://conda.io/projects/conda/en/latest/index.html#
-------- End --------
copyright notice
author[The way of Python data],Please bring the original link to reprint, thank you.
https://en.pythonmana.com/2022/131/202205111424167763.html
The sidebar is recommended
- JSON data storage of MySQL in Python
- Python 3 development function
- My pandas
- Python game programming (pyGame)
- Python word cloud
- Python crawler crawls the Douban movie ranking list and writes it into CSV file for visual data analysis
- Python crawler crawls Beijing Xinfadi vegetables and displays them visually
- Python climbed the world university rankings
- Python crawling material commune picture
- Exception handling in Python and explanation of OS module
guess what you like
Summation of corresponding position elements of multiple lists in Python
[Python pandas] read excel table contents
Python zip() function usage
Application of Python startup subclass subprocess class
Python's logging module
MySQL application of Python
Interesting games designed in Python
Regularity of Python
Build Python project in Jenkins, pychar output is normal and Jenkins output modulenotfounderror: no module named problem
Jenkins reported an error in building Python project: CX_ Oracle. DatabaseError: DPI-1047: oci. dll is not the correct architecture
Random recommended
- Interface request processing of Python webservice
- Hamcrest assertion Library of Python
- Download third-party libraries offline in Python
- Web automation in Python
- Importlib.exe in Python import_ Module import module
- Operation of OS Library in Python
- Some integration operations on Web pages in Python
- Python realizes the super fast window screenshot, automatically obtains the current active window and displays the screenshot
- Implementation of workstation monitoring system with Python socket
- Resume Automation - word 92
- Django foundation -- 02 small project based on Database
- Python drawing word cloud
- Django foundation -- 02 small project based on Database
- MNIST dataset classification based on Python
- Design of FTP client server based on Python
- Signing using RSA algorithm based on Python
- Website backend of online book purchase function based on Python
- Implementation of Tetris game based on Python greedy search
- Django Foundation
- Case: Python weather broadcast system, this is a rainy day
- Python development alert notification SMS alert
- How to configure Python environment library offline in FME
- Python: fastapi - beginner interface development
- Generate password based on fast token and fast token
- [Django CI system] use of json-20220509
- [Django CI system] if the front-end date is complete, it will be fully updated to the back-end; If the front-end date is incomplete, the date will not be updated to the back-end-20220510
- [Django CI system] echarts dataset standard writing - 20220509
- [Django CI system] obtain the current time, the first day and the last day of the month, etc. - 20220510
- wxPython wx. Correction of font class · Wx Font tutorial
- NCT youth programming proficiency level test python programming level 3 - simulation volume 2 (with answers)
- Design of personal simple blog system based on Django (with source code acquisition method)
- [Python Script] classify pictures according to their definition
- Wu Enda's classic ml class is fully upgraded! Update to Python implementation and add more intuitive visual teaching
- Six built-in functions called immortals in Python
- Some insights of pandas in machine learning
- Introduction to Python [preliminary knowledge] - programming idea
- Stay up late to tidy up! Pandas text processing Encyclopedia
- Python recursion to find values by dichotomy
- Open 3D Python Interface
- [true title 02 of Blue Bridge Cup] Python output natural number youth group analysis of true title of Blue Bridge Cup Python national competition