Youth

windows10安装anaconda以及tensorflow遇到的问题

windows10安装anaconda以及tensorflow遇到的问题

安装anaaonda教程:https://blog.csdn.net/ITLearnHall/article/details/81708148

新建虚拟环境

这里我创建的虚拟环境名字为tf2

conda create --name tf2 python=3.7 # “tf2”是你建立的conda虚拟环境的名字 conda activate tf2 # 进入名为“tf2”的conda虚拟环境 如果忘记了名称我们可以先用:conda env list

  • 安装好后,配置用户级环境变量而非系统变量。
  • 不要用conda activate name,而是activate name

CommandNotFoundError: Your shell has not been properly configured to use 'conda activate'. on windows. The fix is to use activate ... instead of conda activate ...

卸载环境

conda remove --name test --all

关于环境总结

`
创建一个名为python34的环境,指定Python版本是3.4(不用管是3.4.x,conda会为我们自动寻找3.4.x中的最新版本)

conda create --name python34 python=3.4

安装好后,使用activate激活某个环境

activate python34 # for Windows

source activate python34 # for Linux & Mac

激活后,会发现terminal输入的地方多了python34的字样,实际上,此时系统做的事情就是把默认2.7环境从PATH中去除,再把3.4对应的命令加入PATH

此时,再次输入

python --version

可以得到Python 3.4.5 :: Anaconda 4.1.1 (64-bit),即系统已经切换到了3.4的环境

如果想返回默认的python 2.7环境,运行

deactivate python34 # for Windows
source deactivate python34 # for Linux & Mac
删除一个已有的环境

conda remove --name python34 --all
`

安装TensorFlow

使用 Python 包管理器 pip 安装 TensorFlow。在命令行下输入:
pip install tensorflow

  • 也可以使用 conda install tensorflow 来安装 TensorFlow,不过 conda 源的版本往往更新较慢,难以第一时间获得最新的 TensorFlow 版本;
  • 如果默认的 pip 和 conda 网络连接速度慢,可以尝试使用镜像,将显著提升 pip 和 conda 的下载速度(具体效果视您所在的网络环境而定);

pip切换为国内源

清华源

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

或:

阿里源

pip config set global.index-url https://mirrors.aliyun.com/pypi/simple/

腾讯源

pip config set global.index-url http://mirrors.cloud.tencent.com/pypi/simple

豆瓣源

pip config set global.index-url http://pypi.douban.com/simple/

conda切换为国内源

conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
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/cloud/msys2/

设置搜索时显示通道地址
conda config --set show_channel_urls yes
注意如果需要pytorch, 还需要添加pytorch的镜像
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/

或者直接修改 .condarc 文件(最强硬)

参考修改 .condarc 文件
Windows 中,该文件的位置在:C:\Users(你的用户名).condarc
Linux 中,该文件的位置在:~/.condarc
如果,没有该文件,应该是你没有选择查看隐藏项目,点击 查看,打开 隐藏的项目 栏;若还是没有,则自己创建一个.condarc文本文件,输入以下内容,然后删除文件后缀名即可
然后,以记事本打开该文件 .condarc,将以下内容复制粘贴到该文件中即可
`show_channel_urls: true
ssl_verify: true
channels:

posted @ 2021-05-16 12:57  lishuaics  阅读(113)  评论(0编辑  收藏  举报