python-在anaconda中配置环境

  • 切换至清华源

conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
conda config --append channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/fastai/
conda config --append channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/
conda config --append channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/bioconda/

  • conda create --name xxxx python==xxxx
    创建环境名以及python版本
  • conda activate xxxxxxx
    转移到要配置的环境名
  • conda install xxxxxxx
    下载所需的库或包
  • 最后检验是否安装成功
  • python
  • import tensorflow as tf
  • print(tf.test.is_gpu_available())
  • quit()
    退出环境

补充1:如何在pycharm中使用刚才配置的环境:

  • ctrl+art+s

  • 点击 python interperation中的设置中的add

  • 点击conda environment 中的exsiting environment

  • 最后添加你想要的环境即可

补充2:使用cmd指令:
在这里插入图片描述
首先跳转到目标环境的地址,之后直接pip安装即可
更快速的方法:点到目标路径,再点击上面的路径输入cmd

补充3:使用pycharm配环境:
有的时候一段新代码会遇到新的库没有装,此时可以直接点击下端terminal界面,然后输入pip install xxxx

在这里插入图片描述

**具体实例:

安装tensorflow1:
python版本:3.6.6
tensorflow版本:tensorflow-gpu == 1.13.1
安装tensorflow2:
python版本:3.7.8
tensorflow版本:tensorflow-gpu==2.1

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值