当前位置:网站首页>Summary and interpretation of CONDA virtual environment
Summary and interpretation of CONDA virtual environment
2022-07-28 03:46:00 【Dream and wake up, happy and carefree】
List of articles
Preface
csdn There is a lot about conda The article , But there has never been a macro article , I will start from a macro perspective , Integrate the article , Reading , Turn new students from conda Environment entry to configuration , Apply the whole process to interpret .
Of course , Because this article is macro , Maybe many students can't understand it at one time , No problem , This can be seen repeatedly , Help can be provided at different stages .
conda Environmental Overview
conda What's the usage?
You usually need to use conda When ,python Have learned a certain degree , Start some applications , Then there will be a scene :A The task requires x,y package ,B The task requires z,w package , however y Bao He z Packet collision , You can't do it at the same time AB Mission .
At this time, you need to use two conda Environmental Science , Install separately xy Packages and zw package , The two environments are isolated from each other , They don't influence each other .
Be specific , such as A The code needs tensorflow 1,B The code needs tensorflow 2, This also requires two environments to host .
further , If you feel that a certain environment is bad , Make a deletion directly , Reloading the environment is also easy .
Good to use , As for the specific how in various IDE of use , How to switch , It is roughly as follows , Very convenient , Once configured, you can switch with one click .

conda Environmental level
I said before. ,conda You can create several virtual environments , Your computer can also be installed python Environmental Science ,miniconda Will also bring their own python Environmental Science , What is the relationship between these environments ?
The first is computer python The environment and Miniconda The environment should be of the same level , When you run it on the command line python When ordered , Which one to choose depends on the configuration of environment variables . Generally installed Miniconda, In particular, add path to... Is checked path after , The default environment will become Miniconda Self contained python.
We call these two basic environments , stay miniconda Usually called base perhaps root.
After is conda create Create a virtual environment , These are all sub environments . Although it is called sub environment , But in practice base It's not much different from other environments , Just can't delete , So logically, we raise him to a higher level , Put the overall package in base in .

Miniconda install
And Anaconda Comparison of
Many people recommend installing anaconda, But I recommend miniconda.
anaconda Equivalent to a lot of bags +conda Tools , But in fact, few of these bags can be used , It takes up too much space , And reloading is also troublesome .
miniconda Equivalent to a little basic package +conda Tools . Just install the missing package by yourself .
I recommend using miniconda Start from scratch , Your understanding of bags will be deeper .
Pay attention to the version and the source of the installation package
Many people like to install higher versions , But you go to see the industry , They are all stable versions , On the one hand, the high version is unstable , On the other hand, the environment is not suitable . It is prone to package conflicts in the basic environment .
So it is recommended to install 3.7 edition 64 Bit Miniconda.
also , It is recommended to download from the official website , Under the mirror website , There may be problems , There is a friend here who has been in the mood of mirror image all afternoon , The result is to switch back to the official website .
conda command
conda There are many commands of tools on the Internet .
It should be noted that , In a virtual environment ( Include base Environmental Science ) When installing the package , As far as possible with conda instead of pip, because conda Better management of package dependencies . When we conda When I can't be safe , Ability to use pip.
Although in conda Used in the environment pip You can also install the package in the virtual environment , But in the end, there will be unknown effects .
conda install package_name
jupyter notebook install + Expand
Installation level
First of all, you need to know ,jupyter notebook It's a IDE, A user only needs one IDE that will do , and IDE You can call various conda A virtual environment , This explanation jupyter notebook The hierarchy of , Should be miniconda Grade , It is at the basic environment level .
So directly in base Run the command to install
jupyter notebook
conda install jupyter
Virtual environment switching plug-in :nb_conda
Virtual environment alone is not enough , If you want to be in jupyter notebook Switch inside , Need a plug-in .
conda install nb_conda
however , Later, we need to conda Installation in environment ipykernel Talent .
Theme switching plug-in :jupyter_themes
Change to a fresh theme , Adjust the layout of fonts , It will be very comfortable .
Extensions collection :nb_extensions
More plug-ins can improve efficiency .
conda Environment creation and basic configuration
Generally, installation requires only two points , One is name, One is python edition
If there is no special requirement , General installation 3.7 perhaps 3.8. No addition python Version command , He'll install 3.10, This version of python It's not very useful .
conda create -n env_name python=3.8
Then you can activate conda The environment is further configured
conda activate env_name
install ipykernel, Otherwise, it will not be nb_conda The plug-in recognizes . Many articles are written about installation jupyter notebook, They compare dishes , Not realizing the essence , It just needs one kernel that will do , There is no need to install the whole jupyter.
conda install ipykernel
conda Perfect environment
Basic commands
Come here , stay jupyter notebook You can switch freely in conda The environment , Then there is environment customization , Install whatever bag you want .
conda install package_name
The case that the package cannot be found
occasionally conda Can't find , You can add -c conda-forge Command use extra , With pynput Library example
conda install pynput -c conda-forge
Last, last , No way out , You can use it again pip
pip install package_name
Download too slow
This is mainly because of the source of the software package
Use scenarios :IDE Use in
jupyter notebook in
Actually, I've finished this before .
vscode&PyCharm
these two items. IDE You can switch the environment in the lower right corner , among conda The environment can also be switched .
Advanced :Miniconda Directory structure

The first level is Miniconda root directory , There are several folders below :
- bin There are binary files
- scripts It is also an executable script file
- Lib yes base Library of environment , among site-packages yes conda install The location of
- envs Is the virtual environment directory .

envs There are several directories under , The directory name corresponds to the virtual environment name

Enter a virtual environment directory ,Lib Under the directory is the library of the virtual environment 
among site-packages yes conda install The location of .
This hierarchy is consistent with what we said earlier , although base When used, it is similar to the virtual environment , But in essence base Is above the virtual environment .
边栏推荐
- 动态规划——509. 斐波那契数
- Advanced Mathematics (Seventh Edition) Tongji University exercises 3-4 personal solutions (the last 8 questions)
- C语言:求一个整数存储在内存中的二进制中1的个数
- Monotonous stack -- 42. Receiving rain -- a difficult problem that big factories must know
- Tungsten Fabric SDN — BGP as a Service
- Leetcode brush question: dynamic planning 09 (weight of the last stone II)
- WordPress简约mkBlog博客主题模板v2.1
- [wrong question]mocha and railgun
- VBA reads the create document of SQL in batches to create tables
- AI chief architect 12 AICA Baidu OCR vertical large-scale landing practice
猜你喜欢

leetcode刷题:动态规划08(分割等和子集)

Weekly recommended short video: how to correctly understand the word "lean"?

695. Maximum area of the island

一文读懂Plato Farm的ePLATO,以及其高溢价缘由

ES6 from entry to mastery 07: Deconstruction assignment

Leetcode skimming: dynamic programming 08 (segmentation and subsets)

Unity simply implements the dialog function

服务器内存故障预测居然可以这样做!

常用的弱网测试工具

Data mining-01
随机推荐
Advanced Mathematics (Seventh Edition) Tongji University exercises 3-6 personal solutions
【OPENVX】对象基本使用之vx_convolution
【图像分类】2021-MLP-Mixer NIPS
Digital economy has become the biggest attraction
Xctf attack and defense world web master advanced area unserialize3
Screenshot of deepstream detection results
[leetcode] 34. Find the first and last positions of elements in the sorted array
[openvx] VX for basic use of objects_ lut
Push chart written by helm to harbor warehouse
In December, the PMP Exam adopted the new syllabus for the first time. How to learn?
VBA reads the create document of SQL in batches to create tables
STM32 RT thread virtual file system mount operation
Ch340 RTS DTR pin programming drives OLED
收藏|0 基础开源数据可视化平台 FlyFish 大屏开发指南
WordPress simple mkblog blog theme template v2.1
一个仿win10蓝屏的404页面源码
做自动化测试,你后悔了吗?
Dynamic planning - 63. Different paths II
LeetCode 0140. 单词拆分 II
动态规划——416. 分割等和子集