简体   繁体   English

Tensorflow pip 在mac上安装python3

[英]Tensorflow pip install on mac with python3

I know this has been asked many times, I saw them tried to solve my problem but I can't, nothing works for me.我知道这已经被问过很多次了,我看到他们试图解决我的问题,但我做不到,对我没有任何作用。

  • I have a mac m1, My os version is BigSur 11.5.1我有一个 mac m1,我的操作系统版本是 BigSur 11.5.1
  • My python3 version is 3.8.10我的python3版本是3.8.10
  • I have a project folder, which I created my env in there as atai_env我有一个项目文件夹,我在那里创建了我的环境作为 atai_env
  • I ran pip upgrade, my pip version is current which is 21.3.1我运行 pip 升级,我的 pip 版本是当前版本,即 21.3.1
  • I activated my env and ran pip install tensorflow which gives this error;我激活了我的环境并运行pip install tensorflow给出了这个错误;

ERROR: Could not find a version that satisfies the requirement tensorflow (from versions: none)错误:找不到满足 tensorflow 要求的版本(来自版本:无)

ERROR: No matching distribution found for tensorflow错误:未找到 tensorflow 的匹配分布

  • I saw some command as pip install tensorflow-macos so I tried it, it seems to install but at the end it gives this Failed to build h5py which I tried to install but failed again我看到一些命令为 pip install tensorflow-macos所以我试了一下,它似乎可以安装但最后它给出了这个Failed to build h5py我试图安装但又失败了
  • Then I tried to ran pip command given here for python 3.8 -> https://www.tensorflow.org/install/pip and it gives below error; Then I tried to ran pip command given here for python 3.8 -> https://www.tensorflow.org/install/pip and it gives below error;

tensorflow-2.7.0-cp38-cp38-macosx_10_11_x86_64.whl is not a supported wheel on this platform. tensorflow-2.7.0-cp38-cp38-macosx_10_11_x86_64.whl 不是该平台支持的轮子。

I am so sick of this:/ I tried to install other versions of python but it always fails.我对此感到非常厌烦:/我尝试安装其他版本的 python 但它总是失败。 Can someone explain what should I do, I can't believe I spent more than 2 hours on this.有人可以解释我该怎么做,我不敢相信我花了超过 2 个小时。 On the tensorflow install page, it seems I should only be running pip install tensorflow but that doesn't work在 tensorflow 安装页面上,看来我应该只运行pip install tensorflow但这不起作用

Ok, Nothing that I found on google helped.好的,我在谷歌上找到的没有任何帮助。 I started over, and decided to try python versions starting from 3.9 with decreasing versions.我重新开始,并决定从 3.9 开始尝试 python 版本,并降低版本。 Finally this command just worked -> pip install tensorflow with python 3.7.9 It is so frustrating, cost me a few hours.最后这个命令才起作用-> pip install tensorflow with python 3.7.9 太令人沮丧了,花了我几个小时。 I wasn't expecting it would be unstable like this.没想到会这么不稳定。 Anyway, if you happen to face it just try to use one of the version 7 even tho tensorflow says it works for 3.7 - 3.9无论如何,如果您碰巧遇到它,请尝试使用版本 7 之一,即使 tensorflow 说它适用于 3.7 - 3.9

PS: I am sorry but this is really stupid, it is almost 2022 and we are working on AI with this framework comon:/ PS:很抱歉,这真的很愚蠢,快到 2022 年了,我们正在使用这个框架共同开发 AI:/

I have MacOS BigSur 11.6.1 running and just created a virtualenv with Python 3.8.12 .我正在运行 MacOS BigSur 11.6.1,并且刚刚使用Python 3.8.12创建了一个virtualenv Installing tensorflow works without any problems:安装tensorflow没有任何问题:

pip install tensorflow

pip install tensorflow                                                                                                                                           1 err | 8s | voice_assistant py 
Collecting tensorflow
  Downloading tensorflow-2.7.0-cp38-cp38-macosx_10_11_x86_64.whl (207.1 MB)

I could successfully install and run TensorFlow from my M1 MacBook Pro.我可以从我的 M1 MacBook Pro 成功安装和运行 TensorFlow。 Monterey 12.4.蒙特雷 12.4。 Here's what I did:这是我所做的:

1. Install Homebrew first 1. 先安装 Homebrew

How typical.多么典型。

2. Install Anaconda via Homebrew 2. 通过 Homebrew 安装 Anaconda

brew install anaconda

Installing Python is a mess and I know most tutorials will suggest to use pyenv as the version management tools.安装 Python 是一团糟,我知道大多数教程都会建议使用pyenv作为版本管理工具。 I tried that, but didn't work.我试过了,但没有用。 What worked for me is Anaconda.对我有用的是 Anaconda。

3. Download PyCharm 3.下载PyCharm

It's a GUI-friendly way to switch between Python versions and environments.这是一种在 Python 版本和环境之间切换的 GUI 友好方式。

4. Set the Python interpreter inside PyCharm 4.在PyCharm里面设置Python解释器

在此处输入图像描述

Note that I use Conda Environment .请注意,我使用Conda Environment Note also that the conda executable is inside /opt/homebrew/anaconda3/bin/conda .另请注意, conda可执行文件位于/opt/homebrew/anaconda3/bin/conda内。

5. Install tensorflow-macos from the PyCharm terminal 5.从PyCharm终端安装tensorflow-macos

After doing this, you can import tensorflow as tf inside your .py files.完成此操作后,您可以在.py文件import tensorflow as tf

You can try upgrading the version of pip.您可以尝试升级 pip 的版本。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM