目录
一、Conda使用
1.1 conda基础命令
1.2 添加第三方源
二、pip常见命令
一、Conda使用
1.1 conda基础命令
打开anaconda Prompt 输入conda list 就会显示已经安装好的库
如果这些库中没有自己需要的库就可以用
anaconda search -t conda tensorflow 查找需要的库这样就会显示你要安装的有哪些版本
然后使用 anaconda show 文件名 就会告诉如何安装对应的库
最后复制上面的install 就可以安装了。
conda 常见的命令
更新:
pip install 库名
pip install 库名 --upgrade
# 或者
conda install 库名
conda update 库名# 更新所有库
conda update --all# 更新 conda 自身
conda update conda# 更新 anaconda 自身
conda update anaconda
1.2 添加第三方源
首先生成 换源文件 【2020-06月】3 个 Anaconda 国内开源镜像站
命令行中直接使用以下命令,生成配置文件 C:\Users\我们的用户名\.condarc
conda config --add channels https://mirrors.bfsu.edu.cn/anaconda/pkgs/main
conda config --add channels https://mirrors.bfsu.edu.cn/anaconda/pkgs/free
conda config --add channels https://mirrors.bfsu.edu.cn/anaconda/pkgs/r
conda config --add channels https://mirrors.bfsu.edu.cn/anaconda/pkgs/pro
conda config --add channels https://mirrors.bfsu.edu.cn/anaconda/pkgs/msys2
conda config --add channels https://mirrors.bfsu.edu.cn/anaconda/cloud/conda-forge
conda config --add channels https://mirrors.bfsu.edu.cn/anaconda/cloud/msys2
conda config --add channels https://mirrors.bfsu.edu.cn/anaconda/cloud/bioconda
conda config --add channels https://mirrors.bfsu.edu.cn/anaconda/cloud/menpo
conda config --add channels https://mirrors.bfsu.edu.cn/anaconda/cloud/pytorch
conda config --add channels https://mirrors.bfsu.edu.cn/anaconda/cloud/simpleitk# 设置搜索时显示通道地址
conda config --set show_channel_urls yes
有时候国内镜像源无法连接,需要恢复原来的源:
conda config --remove-key channels
二、pip常见命令
# 安装python包
pip install 包名# 指定版本号
pip install 包名==版本
pip install 包名>=2.22, <3
pip install 包名!=2.22# 指定镜像源安装
pip install -i url 包名 # 其中国内镜像源( url ) 可以是清华、中科大、豆瓣等
#清华:https://pypi.tuna.tsinghua.edu.cn/simple
#豆瓣:http://pypi.douban.com/simple/# 本地wheel文件安装 whl文件可以去https://www.lfd.uci.edu/~gohlke/pythonlibs/#pyhook离线下载到本地
pip install 包名.whl# github仓库中安装
pip install git+包的github地址# 更新python库
pip install 包名 -U# 查看可提供安装的版本
pip install 包名==lemon# 查看已经安装的python库
pip list
# 查询当前环境可升级的包
pip list -o# 查看python库的信息
pip show 包名
pip show 包名 -f# 卸载包
pip uninstall 包名# 导出依赖包列表 freeze命令, 复用包很方便
pip freeze > requirements.txt # 获取当前环境安装python库的版本信息,导入到txt文件中
# 从依赖包中安装
pip install -r requirements.txt# 将python库制作成wheel文件,可以提供给他人用.whl文件,先安装wheel库
pip install wheel
# 特定python库制作成wheel文件
pip wheel --wheel-dir DIR some-package[==version] # 其中,DIR是保存文件的路径,比如users/lemon/Downloads# 根据依赖包信息,制作wheel文件
pip wheel --wheel-dir DIR -r requirements.txt