《conda用法笔记》
Conda is an open source package management system and environment management system that runs on Windows, macOS and Linux. 方便环境管理的软件,对python环境支持很好,也可以安装编译好的C++的库…
Key Words:conda环境管理、pip环境管理
Agile Pioneer
miniconda 下载地址: https://docs.conda.io/en/latest/miniconda.html
安装命令:bash Anaconda3-5.3.0-Linux-x86_64.sh
在会话框中指定一个文件夹(注意不要提前创建)
搞一个 set_env.sh 文件添加:export PATH=$PATH:/home/xxxx/env/bin(会话框中指定的文件夹)
参考:https://zhuanlan.zhihu.com/p/50302396
安装Anaconda
https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/
使用pip来保存当前运行环境所依赖的版本
参考 https://zhuanlan.zhihu.com/p/22678445
首先要下载一个miniconda
通过conda在系统中搞两个python环境
conda search pyqtgraph
conda info package_name
conda info package_name==0.0.1(version)
conda install=version=specific
conda info -e
conda install --use-local xxx.tar.bz
如果报错 EOFError:Compressed file ended before the end-of-stream marker was reached
说明已经有这个缓存包了,下载了一部分,没下载全,用conda clean命令清除
conda clean -t
conda update numpy
pip install --upgrade pip
(注意至少需要指定python版本或者要安装的包)
# conda create -n env_name
conda create -n env_name python=3.5
conda create -n env_name numpy matplotlib python=3.5
从另一个环境直接复制的方式创建
conda create -n B --clone A
source activate env_name
source deactive env_name
conda remove -n env_name --all
# 导出当前环境:
conda env export > py36.yaml
# 会生成一个py36.yaml文件,将其复制到目标机上后执行导入环境操作:
conda env create -f py36.yaml
conda clean -p // 删除没有用的包
conda clean -t // 删除所有的包
# 下载包的方式1 指定一个环境去下载包
conda install -n env_name pandas
conda list -n env_name
# 下载包的方式2 切换到一个环境下再下载包
source activate env_name
conda install pandas
conda config --show-sources
# or
vi .condarc
# 清华大学TUNA镜像源
https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/conda
# 中国科学技术大学 USTC Mirror
- 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/
# 上海交大开源镜像
- https://mirrors.sjtug.sjtu.edu.cn/anaconda/pkgs/main/
- https://mirrors.sjtug.sjtu.edu.cn/anaconda/pkgs/free/
- https://mirrors.sjtug.sjtu.edu.cn/anaconda/cloud/conda-forge/
# 添加conda源的命令,需要去掉网址的引号
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/conda
# 显示urls
conda config --set show_channel_urls yes
channels:
- 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/
- defaults
show_channel_urls: yes
conda config --remove-key channels
### conda copy
conda create --name python32 --clone python321
conda remove --name old_name --all # or its alias: `conda env remove --name old_name
pycharm -> settings -> Project Interpreter -> 右上侧点击齿轮
-> Add local 选择到python执行文件的bin目录下
确认即可
参考: https://mirrors.tuna.tsinghua.edu.cn/help/pypi/
根目录创建.pip文件:mkdir ~/.pip
创建文件pip.conf:vim .pip/pip.conf
在pip.conf中添加内容如下:
[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
trusted-host = pypi.tuna.tsinghua.edu.cn
#这个更换的是清华的源,清华的源5分钟同步官网一次,建议使用。另附上其他源:
#清华大学 https://pypi.tuna.tsinghua.edu.cn/simple/
#阿里云 http://mirrors.aliyun.com/pypi/simple/
#中国科技大学 https://pypi.mirrors.ustc.edu.cn/simple/
#豆瓣(douban) http://pypi.douban.com/simple/
#中国科学技术大学 http://pypi.mirrors.ustc.edu.cn/simple/
~/.cache/pip/