Blogger Information
Blog 291
fans 0
comment 0
visits 350735
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
Anaconda环境配置
Original
1003 people have browsed it

镜像下载、域名解析、时间同步请点击 阿里巴巴开源镜像站

前言

Anaconda环境配置

Anaconda安装完后要进行环境配置,环境配置就是安装虚拟环境,让程序可以在这个环境中运行!

一、Anaconda为什么要进行环境配置?

就是给程序代码一个家,让它有安身之所可以运行!

二、使用步骤

1.查看虚拟环境

conda info —envs

  1. C:\Users\LENOVO>conda info --envs
  2. # conda environments:
  3. #
  4. base * D:\wenlifen.com
  5. fine D:\wenlifen.com\envs\fine
  6. tensorflow D:\wenlifen.com\envs\tensorflow

这表示有3个虚拟环境,虚拟环境可以安装很多

2.创建虚拟环境

conda create —name 虚拟环境名 python=3.7

  1. C:\Users\LENOVO>conda create --name fen python=3.7
  2. ................
  3. Proceed ([y]/n)? y

注意:conda 赋值版本用 “=” ,pip 赋值版本用 “==” ,python如果不写版本,也会有默认版本。

3.查看某个虚拟环境有哪些库

conda list —name 虚拟环境名

  1. C:\Users\LENOVO>conda list --name fen
  2. # packages in environment at D:\wenlifen.com\envs\fen:
  3. #
  4. # Name Version Build Channel
  5. ca-certificates 2021.10.26 haa95532_2
  6. certifi 2021.10.8 py37haa95532_0
  7. openssl 1.1.1l h2bbff1b_0
  8. pip 21.2.4 py37haa95532_0
  9. python 3.7.11 h6244533_0
  10. setuptools 58.0.4 py37haa95532_0
  11. sqlite 3.36.0 h2bbff1b_0
  12. vc 14.2 h21ff451_1
  13. vs2015_runtime 14.27.29016 h5e58377_2
  14. wheel 0.37.0 pyhd3eb1b0_1
  15. wincertstore 0.2 py37haa95532_2

Name 中表示有哪些库

4.激活虚拟环境

activate 虚拟环境名

  1. C:\Users\LENOVO>activate fen
  2. (fen) C:\Users\LENOVO>

这表示进入虚拟环境中,可以在里面下载或删除库

下载库:

  1. (fen) C:\Users\LENOVO>pip install numpy==1.19.0

也可以在阿里云镜像网站下载
pip install 库名 -i 网站名

删除库:

  1. (fen) C:\Users\LENOVO>pip uninstall numpy==1.19.0

5.退出虚拟环境

conda deactivate

  1. (fen) C:\Users\LENOVO>conda deactivate

6.删除虚拟环境

conda remove —name 虚拟环境名 —all

  1. C:\Users\LENOVO>conda info --envs
  2. # conda environments:
  3. #
  4. base * D:\wenlifen.com
  5. fen D:\wenlifen.com\envs\fen
  6. fine D:\wenlifen.com\envs\fine
  7. tensorflow D:\wenlifen.com\envs\tensorflow
  1. C:\Users\LENOVO>conda remove --name fen --all
  2. ................
  3. Proceed ([y]/n)? y
  4. ................
  5. C:\Users\LENOVO>conda info --envs
  6. # conda environments:
  7. #
  8. base * D:\wenlifen.com
  9. fine D:\wenlifen.com\envs\fine
  10. tensorflow D:\wenlifen.com\envs\tensorflow

7.如果创建虚拟环境时没有安装python,虚拟环境中就没有库,我们可以进入虚拟环境中安装

  1. C:\Users\LENOVO>conda create --name fen
  2. ..........
  3. Proceed ([y]/n)? y
  4. ..........
  5. C:\Users\LENOVO>conda list --name fen
  6. # packages in environment at D:\wenlifen.com\envs\fen:
  7. #
  8. # Name Version Build Channel
  9. C:\Users\LENOVO>activate fen
  10. C:\Users\LENOVO>conda.bat activate fen
  11. (fen) C:\Users\LENOVO>conda install python=3.7
  12. ........
  13. Proceed ([y]/n)? y
  14. ........
  15. (fen) C:\Users\LENOVO>conda deactivate
  16. C:\Users\LENOVO>conda list --name fen
  17. # packages in environment at D:\wenlifen.com\envs\fen:
  18. #
  19. # Name Version Build Channel
  20. ca-certificates 2021.10.26 haa95532_2
  21. certifi 2021.10.8 py37haa95532_0
  22. openssl 1.1.1l h2bbff1b_0
  23. pip 21.2.4 py37haa95532_0
  24. python 3.7.11 h6244533_0
  25. setuptools 58.0.4 py37haa95532_0
  26. sqlite 3.36.0 h2bbff1b_0
  27. vc 14.2 h21ff451_1
  28. vs2015_runtime 14.27.29016 h5e58377_2
  29. wheel 0.37.0 pyhd3eb1b0_1
  30. wincertstore 0.2 py37haa95532_2

注意 下载python用conda不要用pip

总结

环境配置就是安装虚拟环境,虚拟环境中安装库的方法有很多,也可有在Anaconda中安装!

本文转自:https://blog.csdn.net/qq_54180801/article/details/121843467

Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post