第一次在mac上安装tensorflow

因为电脑安装的anaconda是python3.9版本,下意识的安装tensor flow的定义python版本就下了3.9(这里有一个坑)

## 终端命令
`conda create -n tensorflow python=3.9`

看似一帆风顺的安装界面

第二步激活tensor flow环境

#终端命令
conda activate tensorflow

第三步安装tensor flow (问题来了)

#安装命令
conda install tensorflow

报错如下,大概是说不支持python版本3.9,支持的版本包括2.7,3.7,3.6,3.5

Collecting package metadata (current_repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.
Solving environment: failed with repodata from current_repodata.json, will retry with next repodata source.
Collecting package metadata (repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.
Solving environment: \ 
Found conflicts! Looking for incompatible packages.
This can take several minutes.  Press CTRL-C to abort.
failed                                                                          

UnsatisfiableError: The following specifications were found
to be incompatible with the existing python installation in your environment:

Specifications:

  - tensorflow -> python[version='2.7.*|3.7.*|3.6.*|3.5.*']

Your python: python=3.9

If python is on the left-most side of the chain, that's the version you've asked for.
When python appears to the right, that indicates that the thing on the left is somehow
not available for the python version you are constrained to. Note that conda will not
change your python version to a different minor version unless you explicitly specify
that.

第四步,将python版本降级,我是从3.9改成了3.6

#命令
conda install python=3.6

第五步,再来一次安装

conda install tensorflow

安装成功,但是真的好慢
第六步,检查一下
成功加载~
相比较网上的其他教程,这个安装方法亲测有效,且比较简单,只需要4步。

Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐