当前位置:   article > 正文

Mac M1 安装 TensorFlow 使用Python3.8_mac python3 install tensorflow

mac python3 install tensorflow

适用Mac M1 11.4+ Python是3.8

需要下载Miniforge3 我的百度云
链接: https://pan.baidu.com/s/1auIBzudS8Y_8TsWMNsiMSQ 提取码: d6ps

1 我安装了anaconda 为了使用conda

链接地址:Anaconda3-2021.05-MacOSX-x86_64.pkg 对应的版本安装后都有conda了

2 安装完后打开一个终端 输入conda -V 显示如下:即能看到conda的版本即可

在这里插入图片描述

3 从下载的百度云中找到Miniforge3-MacOSX-arm64.sh 然后在终端中输入:

bash Miniforge3-MacOSX-arm64.sh(终端要进入到Miniforge3-MacOSX-arm64.sh文件所在的目录下)

4 结束后在终端中输入命令:vim ~/.bash_profile

在这里插入图片描述
看到如下内容:
在这里插入图片描述
在这里插入图片描述

miniforge3 的路径的获取的方式:

在这里插入图片描述
即一般情况是在自己的用户目录下

5激活 .bash_profile 即在终端中输入:

source ~/.bash_profile 关闭终端,打开一个 新终端

6 创建3.8的虚拟环境

代码如下:

conda create -n 自己想用的虚拟环境名称 python=3.8               
例如:
conda create -n jjwtf python=3.8
  • 1
  • 2
  • 3

如果创建的过程中出现下边这个,则输入y回车
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

7

在这里插入图片描述

8 不用退出虚拟环境,直接进入arm64的目录下

在这里插入图片描述
不用退出虚拟环境,直接进入arm64的目录下 再次强调一遍

9 先到arm64目录下,在虚拟环境中分别执行如下命令(只要想用TensorFlow的虚拟环境都要执行此代码)另外如果安装其他包把这几个更改了则需要重新安装这几个包

pip install --force pip==20.2.4 wheel setuptools cached-property six
pip install --upgrade --no-dependencies --force grpcio-1.33.2-cp38-cp38-macosx_11_0_arm64.whl   # 如果改了需要重新安装
pip install --upgrade --no-dependencies --force h5py-2.10.0-cp38-cp38-macosx_11_0_arm64.whl     # 如果改了需要重新安装
pip install --upgrade --no-dependencies --force numpy-1.18.5-cp38-cp38-macosx_11_0_arm64.whl  # 如果改了需要重新安装
pip install --upgrade --no-dependencies --force tensorflow_addons_macos-0.1a3-cp38-cp38-macosx_11_0_arm64.whl   # 如果改了需要重新安装
pip install absl-py astunparse flatbuffers gast google_pasta keras_preprocessing opt_einsum protobuf tensorflow_estimator termcolor typing_extensions wrapt wheel tensorboard typeguard
pip install --upgrade --force --no-dependencies tensorflow_macos-0.1a3-cp38-cp38-macosx_11_0_arm64.whl   # 如果改了需要重新安装
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7

安装jupyter 然后就可以使用TensorFlow了

在这里插入图片描述
conda install jupyter

在输入jupyter notebook

在这里插入图片描述
就可以了
在这里插入图片描述
导入成功
在这里插入图片描述

备注: 查看自己创建了多少虚拟环境的命令:

conda info --envs 或者用此命令 conda env list
删除的命令是 :conda remove -n 你自己的虚拟环境的名字 --all 例如: conda remove -n pytf --all

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/weixin_40725706/article/detail/446815
推荐阅读
相关标签
  

闽ICP备14008679号