1.查看当前环境
打开anaconda prompt,输入
conda env list
这个是已经安装好的样子,如果没有安装好的话就是只有base。
2.创建环境
conda create -n tensorflow python=3.9
如果出现报错
CondaHTTPError: HTTP 000 CONNECTION FAILED for url
报错原因:conda无法创建虚拟环境并且无法安装其他第三方包。
参考优快云博客解决方法:解决Anaconda出现CondaHTTPError: HTTP 000 CONNECTION FAILED for url问题
错误原因:默认镜像源访问速度过慢,并删除默认镜像源
解决方法:
2.1.在cmd中输入以下几条命令,或在C/用户/127中以txt格式打开进行直接的删除和修改
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/msys2/
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 --set show_channel_urls yes
2.2.打开文件夹,并且删除“deflauts”那一行
2.3.更改检测中断时间
remote_read_timeout_secs:1000.0
3.打开tensorflow配置环境,安装tensorflow
activate tensorflow
4.搜索适用于此电脑的tensorflow版本
conda search --full --name tensorflow
选择合适的版本后,进行安装
5.安装
pip install tensorflow==2.6.0 (我使用的是上面这一种)
pip install tensorflow==2.6.0 -i https://pypi.tuta.tsinghua.edu.cn/simple (国内镜像网站,速度会快一点)(推荐使用下面,如果报错,使用上面那一种)
6.检查是否安装完成
python #进入python环境中
import tensorflow as tf
tf.__version__
出现‘2.6.0’,表示测试成功
如有错误,希望指正,谢谢!❤