current position:Home>Introduction to Python - CONDA common commands
Introduction to Python - CONDA common commands
2022-01-30 06:25:52 【Why】
- Little knowledge , Great challenge ! This article is participating in “ A programmer must have a little knowledge ” Creative activities .
This paper introduces the use of conda management anaconda Python Environment related commands .
conda Environment related commands
Create an environment
conda create -n env_name python=3.7 --clone another_env
Copy code
-n:name Indicates the name of the new environment
python: Use python edition
--clone: Copy from existing environment
Delete environment
conda remove -n env_name --all
Copy code
Look at the environment
conda env list
Copy code
or
conda info -e
Copy code
Activate the environment
conda activate env_name
Copy code
or
source activate env_name
Copy code
Out of the environment
conda deactivate
Copy code
or
source deactivate
Copy code
Will return to
base
Environmental Science
conda Package related commands
View the current environment conda Managed python Package list
conda list
Copy code
install python package
conda install package_name # Installation package
conda install package_name_1 package_name_2 package_name_3 ... # Install multiple packages at a time
conda install package_name=1.1.0 # Install the specified version of the package
Copy code
Update package
conda update package_name # Update package
conda upgrade --all # Update all packages
Copy code
Uninstall package
conda remove package_name
Copy code
Search for packages with unclear names
conda search search_term
Copy code
conda Recreate the environment
Use conda management python An important consideration is portability ,conda Several methods are provided for reproducing a conda Environmental Science .
Clone
This command has been described above , Used to reproduce an environment locally
conda create --name new_env --clone old_env
Copy code
Spec List
Copy the environment between computers with the same operating system , Can generate
spec list
# Generate spec list file
conda list --explicit > spec-list.txt
# Recreate the environment :
conda create --name python-course --file spec-list.txt
Copy code
Environment.yml
Use -export Option to generate a
environment.yml
file , To replicate the project environment between different platforms and operating systems .spec list Document and
environment.yml
The difference between files is :environment.yml
Files are not specific to a particular operating system , And use YAML Format .environment.yml
Only the package name is listed , from conda Build the environment based on the name of the package . Another difference is -export It also includes the use of pip Installed packages , andspec list
There is no .
# export environment.yml file :
conda env export > environment.yml
# Recreate the environment :
conda env create -f environment.yml
Copy code
Be careful : If the current path already has environment.yml file ,conda Will rewrite this file
Conda Pack
The above two reproduction methods are based on recording the current environment package information , To the idea of new machine reconstruction . and Conda Pack It is used to package the files of the current environment directly , The idea of unpacking the new machine .
conda-pack Specify the platform and operating system , The target computer must have the same platform and operating system as the source computer .
install conda pack
# from conda
conda install -c conda-forge conda-pack
# from pip
pip install conda-pack
Copy code
Packaging environment
conda pack -n my_env
conda pack -n my_env -o out_name.tar.gz
Copy code
Recreate the environment
mkdir -p path_to_my_new_env # Advice on anaconda Of envs In the folder
tar -xzf my_env.tar.gz -C path_to_my_new_env # Unzip the files in the package
source path_to_my_new_env/bin/activate # Activate the environment
(my_env) $ python # Let's take a look at python Then exit
(my_env) $ conda-unpack # Very important , Please don't ignore
Copy code
copyright notice
author[Why],Please bring the original link to reprint, thank you.
https://en.pythonmana.com/2022/01/202201300625503837.html
The sidebar is recommended
- [recalling the 1970s] using Python to repair the wonderful memories of parents' generation, black-and-white photos become color photos
- You used to know Python advanced
- Pyinstaller package Python project
- 2021 IEEE programming language rankings: Python tops the list!
- Implementation of Python automatic test control
- Python advanced: [Baidu translation reverse] graphic and video teaching!!!
- Do you know the fuzzy semantics in Python syntax?
- [Python from introduction to mastery] (XXVII) learn more about pilot!
- Playing excel office automation with Python
- Some applications of heapq module of Python module
guess what you like
-
Python and go languages are so popular, which is more suitable for you?
-
Python practical skills task segmentation
-
Python simulated Login, numpy module, python simulated epidemic spread
-
Python opencv contour discovery function based on image edge extraction
-
Application of Hoff circle detection in Python opencv
-
Python reptile test ox knife (I)
-
Day 1: learn the Django framework of Python development
-
django -- minio_ S3 file storage service
-
[algorithm learning] 02.03 Delete intermediate nodes (Java / C / C + + / Python / go)
-
Similarities and differences of five pandas combinatorial functions
Random recommended
- Learning in Python + opencv -- extracting corners
- Python beginner's eighth day ()
- Necessary knowledge of Python: take you to learn regular expressions from zero
- Get your girlfriend's chat records with Python and solve the paranoia with one move
- My new book "Python 3 web crawler development practice (Second Edition)" has been recommended by the father of Python!
- From zero to familiarity, it will take you to master the use of Python len() function
- Python type hint type annotation guide
- leetcode 108. Convert Sorted Array to Binary Search Tree(python)
- For the geometric transformation of Python OpenCV image, let's first talk about the extraordinary resize function
- leetcode 701. Insert into a Binary Search Tree (python)
- For another 3 days, I sorted out 80 Python datetime examples, which must be collected!
- Python crawler actual combat | using multithreading to crawl lol HD Wallpaper
- Complete a python game in 28 minutes, "customer service play over the president card"
- The universal Python praise machine (commonly known as the brushing machine) in the whole network. Do you want to know the principle? After reading this article, you can write one yourself
- How does Python compare file differences between two paths
- Common OS operations for Python
- [Python data structure series] linear table - explanation of knowledge points + code implementation
- How Python parses web pages using BS4
- How do Python Network requests pass parameters
- Python core programming - decorator
- Python Network Programming -- create a simple UPD socket to realize mutual communication between two processes
- leetcode 110. Balanced Binary Tree(python)
- Django uses Django celery beat to dynamically add scheduled tasks
- The bear child said "you haven't seen Altman" and hurriedly studied it in Python. Unexpectedly
- Optimization iteration of nearest neighbor interpolation and bilinear interpolation algorithm for Python OpenCV image
- Bilinear interpolation algorithm for Python OpenCV image, the most detailed algorithm description in the whole network
- Use of Python partial()
- Python game development, pyGame module, python implementation of angry birds
- leetcode 1104. Path In Zigzag Labelled Binary Tree(python)
- Save time and effort. 10 lines of Python code automatically clean up duplicate files in the computer
- Learn python, know more meat, and be a "meat expert" in the technical circle. One article is enough
- [Python data structure series] "stack (sequential stack and chain stack)" -- Explanation of knowledge points + code implementation
- Datetime module of Python time series
- Python encrypts and decrypts des to solve the problem of inconsistency with Java results
- Chapter 1: introduction to Python programming-4 Hello World
- Summary of Python technical points
- 11.5K Star! An open source Python static type checking Library
- Chapter 2: Fundamentals of python-1 grammar
- [Python daily homework] day4: write a function to count the number of occurrences of each number in the incoming list and return the corresponding dictionary.
- Python uses turtle to express white