Anaconda下的清华镜像添加、Tensorflow2.3安装以及pip&conda基本命令

Anaconda下的清华镜像添加

在已经安装Anaconda之后,添加清华镜像

1.打开【Anaconda prompt】,输入命令: conda config --set show_channel_urls yes

2.在C:\Users\administer目录下生成.condarc文件(Windows用户)

3.打开.condarc 文件,清空此文件,并把下面内容复制进去,保存**(这一步可能会更新,可直接进上面清华镜像网站查看)**:

channels:
  - defaults
show_channel_urls: true
default_channels:
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2
custom_channels:
  conda-forge: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  msys2: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  bioconda: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  menpo: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  pytorch: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  simpleitk: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud

即可添加 Anaconda Python 免费仓库。

4.打开【Anaconda Prompt】:

# 要创建或修改文件(这一步可能是把修改的配置生效了吧)
conda config --add channels conda-forge
#运行 conda clean -i  清除索引缓存,保证用的是镜像站提供的索引。
conda clean -i   

Tensorflow2.3安装

按win+r键,输入cmd,打开Terminal:

第一步 创建独立环境并激活

conda create --name tensorflow2_3 python==3.7
activate tensorflow2_3

第二步 安装相关软件包
第一种:conda install numpy matplotlib PIL scikit-learn pandas
第二种:pip install numpy matplotlib Pillow scikit-learn pandas -i https://pypi.tuna.tsinghua.edu.cn/simple
推荐用pip进行安装

第三步 安装TensorFlow2.3

默认CPU

pip install tensorflow==2.3.0 -i https://pypi.tuna.tsinghua.edu.cn/simple

安装带GPU的

pip install tensorflow-gpu==2.3.0 -i https://pypi.tuna.tsinghua.edu.cn/simple

第四步 测试TensorFlow2.3
在命令行中输入python,打开python交换模式
输入代码:import tensorflow as tf

pip&conda基本命令

conda命令
安装包conda install <package_names>
卸载包conda remove <package_names>
更新包conda update <package_names>
模糊查询conda search <text>

pip命令
安装包pip install <package_names>
卸载包pip uninstall <package_names>

conda环境管理
创建环境conda create --name <env_name> <package_names>
激活环境activate <env_name>
退出环境deactivate
删除环境conda remove --name <env_name> --all
查看当前环境系统以及创建的当前环境的信息conda env list

其他问题

pip install -r 中r什么意思?

经常用,pip install -r requirement.txt,但是确不知道 -r 是什么意思,你说你是不是这样?

下面介绍下,pip install 的几种参数:

-r:通过requirements文件可控地安装很多依赖。

pip install -r requirements.txt

-r, --requirement Install from the given requirements file. This option can be used multiple times.

-t: 安装到指定位置

-e: 安装可编辑的包。不同项目,但是一个项目依赖时使用。

  • 4
    点赞
  • 23
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

留在风中的巧克力

今天天气很好

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值