Allen's blog Allen's blog
首页
面经
算法 (opens new window)
分类

Allen

前端CV工程师
首页
面经
算法 (opens new window)
分类
  • 包管理工具conda

    • conda常用命令
      • conda 换源:
      • pip 换源:
        • linux 平台
        • windows 平台
      • conda 常用命令
      • conda 导出导入依赖表 requirements.txt
      • pip 和 conda 安装依赖表 requirements.txt
  • matplotlib绘图

  • 常用系统知识

  • 一些问题及解决方案

  • python
  • 包管理工具conda
Allen
2023-02-16
目录

conda常用命令

参考文章:conda 常用命令汇总 (opens new window)

查看源:conda config --show channels

# conda 换源:

conda config --add channels http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --add channels http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
conda config --add channels http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/
conda config --add channels http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
conda config --add channels http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/msys2/
conda config --add channels http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/menpo/
conda config --add channels http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/bioconda/
conda config --set show_channel_urls yes
1
2
3
4
5
6
7
8

# pip 换源:

# linux 平台

  1. 在用户目录下新建文件夹~/.pip
    mkdir ~/.pip
    
    1
  2. 新建或者打开配置文件~/.pip/pip.conf
    [global]
    index-url = https://pypi.tuna.tsinghua.edu.cn/simple
    [install]
    trusted-host = https://pypi.tuna.tsinghua.edu.cn
    
    1
    2
    3
    4

# windows 平台

在 C 盘用户目录下找到自己用户名,进入目录后,新建.pip文件夹,并在.pip文件夹下新建pip.ocnf,编辑文件:

    [global]
    index-url = https://pypi.tuna.tsinghua.edu.cn/simple
    [install]
    trusted-host = https://pypi.tuna.tsinghua.edu.cn
1
2
3
4

高版本pip支持命令行配置:

pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
1

国内源:

阿里云 http://mirrors.aliyun.com/pypi/simple/

中国科技大学 https://pypi.mirrors.ustc.edu.cn/simple/

豆瓣(douban) http://pypi.douban.com/simple/

清华大学 https://pypi.tuna.tsinghua.edu.cn/simple/

中国科学技术大学 http://pypi.mirrors.ustc.edu.cn/simple/

# conda 常用命令

查看相关信息:conda info

当前所有的 conda 环境:conda env list

查看当前环境安装的包:conda list

新建环境:conda create [-n env_name | -p path] [--clone env_name] [-c channel_address] [packages]

激活环境:conda activate my_env

退出环境:conda deactivate

安装依赖:conda install [-n env_name | -p path] [-c channel_address] [packages]

移除依赖:conda remove [-n env_name | -p path] [packages] [--all]

# conda 导出导入依赖表 requirements.txt

# 导出依赖表
conda list -e > requirements.txt
# 根据依赖表安装依赖
conda install --yes --file requirements.txt
1
2
3
4

# pip 和 conda 安装依赖表 requirements.txt

不推荐pip freeze > requirements.txt pip freeze 会将当前 PC 环境下所有的安装包都进行生成,再进行安装的时候会全部安装很多没有的包.耗时耗力其实是不可取的。 使用pipreqs,这个工具的好处是可以通过对项目目录的扫描,发现使用了哪些库,生成依赖清单。

安装工具:

pip install pipreqs
1

导出依赖表:

# 导出依赖表
pipreqs ./ --encoding=utf8
# 根据依赖表安装依赖
pip install -r requirements.txt
1
2
3
4
上次更新: 2023/12/16, 09:22:46
matplotlib绘制曲线并输出矢量图

matplotlib绘制曲线并输出矢量图→

最近更新
01
rollup使用配置文件rollup.config.ts打包
12-08
02
package.json导出类型
12-08
03
关键问题方案
11-17
更多文章>
Theme by Vdoing | Copyright © 2023-2023 Allen | Github
  • 跟随系统
  • 浅色模式
  • 深色模式
  • 阅读模式