前言
之前对conda,pip等包管理工具一直是胡乱的使用,没有详细的了解过其使用方法和技巧,导致常见的问题经常反复查询解决方法浪费时间。今天从头到尾看了一下conda的docs,再次大致记录一下,方便以后查询。
PS:其实经常遇到的问题,以及解决方法docs上面都有较详细的记录。系统性比博客要好很多。
conda docs:https://conda.io/docs/user-guide/index.html
什么是conda
- Query and search the Anaconda package index and current Anaconda installation.
- Create new conda environments.
- Install and update packages into existing conda environments.
以上是docs中给出的,大致归纳为2点,一个是管理环境env,另一个是管理python包package。
管理环境和virtualenv也差不了太多,因为本人基本都在本地玩耍,所以这里体会并不是很深。另外conda还是一个跨平台的管理工具,其出身于python社区所以和python经常同台出现。
install conda
安装minconda或anaconda进行安装,前者是简化版本,只包含conda和其依赖。如果安装环境有python相关包也没有关系,不需要进行卸载。
anaconda支持windows、mac和linux系统,且有两个类型的版本,分别是GUI和command line版本,前者是图形界面,后者是命令行界面,占用资源较少。
conda有python3.x和python2.x系列两个版本,其实都没有关系,因为你在使用conda进行创建环境时,可以指定python的版本。
常用命令
查看版本
conda --version
conda -V
查看帮助
conda --help
创建环境(~/anaconda2/envs/xxx 路径)
conda create --name [envname] [dependent package list]
eg:
conda create --name env_test numpy
拷贝环境
conda create --name xxxx --clone yyy
激活环境
linux macOS:source activate [envname]
windows:activate [envname]
失效 deactivate 激活 activate
查看当前环境
conda info --envs
删除环境
conda remove --name xxx
安装包
conda install [package]
conda list 查看当前环境安装的package
pip 与 conda
链接:https://conda.io/docs/user-guide/tutorials/index.html
上述链接里面介绍了conda包的结构以及打包方法,pypi上的包可以通过conda build打成conda包。conda和pypi一样有自己的资源库,可以在config里面进程配置,不过这里一般默认,不做过多介绍。
同:
+ 都是包管理工具
+ 对于默认环境安装方法类似,且都有效
+ 都有依赖管理
不同:
+ 资源位置不同,conda有自己的仓库。
+ conda把python也当做包处理
+ conda可以指定隔离环境安装指定包
常见问题
这里做一下搬运工好勒,常见的问题下面链接都讲得很详细。
+ Permission denied errors during installation
+ Permission denied errors after using sudo conda command
+ Already installed error message
+ Conda reports that a package is installed, but it appears not to be
+ pkg_resources.DistributionNotFound: conda==3.6.1-6-gb31b0d4-dirty
+ macOS error “ValueError unknown locale: UTF-8”
+ AttributeError or missing getproxies
+ Shell commands open from the wrong location
+ Programs fail due to invoking conda Python instead of system Python
+ UnsatisfiableSpecifications error
+ Package installation fails from a specific channel
+ Conda automatically upgrades to unwanted version
+ ValidationError: Invalid value for timestamp
+ Unicode error after installing Python 2
+ https://conda.io/docs/user-guide/troubleshooting.html
828

被折叠的 条评论
为什么被折叠?



