简体   繁体   English

安装 Tensorflow 时出错 - Python 3.8

[英]Error when installing Tensorflow - Python 3.8

I'm new to programming and following a course where I must install Tensorflow.我是编程新手,并且正在学习必须安装 Tensorflow 的课程。 The issue is that I'm using Python 3.8 which I understand isn't supported by Tensorflow.问题是我使用的是 Python 3.8,我知道 Tensorflow 不支持它。

I've downloaded Python 3.6 but I don't know how to switch this as my default version of python.我已经下载了 Python 3.6,但我不知道如何将其切换为我的默认 Python 版本。

Would it be best to set up a venv using python 3.6 for my program and install Tensorflow in this venv?最好使用 python 3.6 为我的程序设置一个 venv 并在这个 venv 中安装 Tensorflow 吗?

Also, I using Windows and Powershell.另外,我使用 Windows 和 Powershell。

Tensorflow is only supported until python 3.7 as of now. Tensorflow 仅在 Python 3.7 之前受支持。 You can check it here: https://www.tensorflow.org/install/pip你可以在这里查看: https : //www.tensorflow.org/install/pip

But there is a way to install it on Python3.8, just run the below command that will do your job:但是有一种方法可以在 Python3.8 上安装它,只需运行以下命令即可完成您的工作:

python -m pip install --upgrade https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-1.12.0-py3-none-any.whl

This command work on mac and windows both, I haven't tested on Linux.这个命令在 mac 和 windows 上都可以使用,我没有在 Linux 上测试过。

You should always use venv because by default every project on your system will use these same directories to store and retrieve site packages (third party libraries).您应该始终使用 venv,因为默认情况下,您系统上的每个项目都将使用这些相同的目录来存储和检索站点包(第三方库)。 At first glance, this may not seem like a big deal, and it isn't really, for system packages (packages that are part of the standard Python library), but it does matter for site packages.乍一看,这对于系统包(属于标准 Python 库的包)来说似乎没什么大不了的,但实际上对于站点包来说却很重要。

Consider the following scenario where you have two projects: ProjectA and ProjectB, both of which have a dependency on the same library, ProjectC.考虑以下场景,其中您有两个项目:ProjectA 和 ProjectB,它们都依赖于同一个库 ProjectC。 The problem becomes apparent when we start requiring different versions of ProjectC.当我们开始需要不同版本的 ProjectC 时,问题就变得明显了。 Maybe ProjectA needs v1.0.0, while ProjectB requires the newer v2.0.0.也许 ProjectA 需要 v1.0.0,而 ProjectB 需要更新的 v2.0.0。

You can also take a look at anaconda, it's the most populasr data sciencie platform and will be easy for you install tensorflow and jupiter notebook in just 2 clicks.您还可以查看 anaconda,它是最受欢迎的数据科学平台,只需单击 2 次,您就可以轻松安装 tensorflow 和 jupiter notebook。 Anaconda蟒蛇

Uninstall all your python versions and use the latest anaconda .卸载所有 python 版本并使用最新的anaconda

$ conda create --name tensorflow python=3.5

This way you create a virtual environment with python 3.5 which is supported by tensorflow.通过这种方式,您可以使用 tensorflow 支持的 python 3.5 创建虚拟环境。

So now you can install it.所以现在你可以安装它了。

$ activate tensorflow
(tensorflow) $ pip install tensorflow

it would have been nice if you would have the share the error screenshot though as per i got the case如果你能分享错误屏幕截图就好了,尽管按照我的情况

tensorflow work in both 3.8 and 3.6 just you have to check that you have 64bit version not 32 bit tensorflow 在 3.8 和 3.6 中都可以工作,只是你必须检查你有 64 位版本而不是 32 位

you can acess both version from thier respective folder no need to install a venv您可以从各自的文件夹中访问这两个版本,无需安装 venv

If you don't want to use Anaconda or virtualenv, then actually multiple Python versions can live side by side.如果您不想使用 Anaconda 或 virtualenv,那么实际上多个 Python 版本可以并存。 I use Python38 as my default and Python35 for TensorFlow until they release it for Python38.我使用 Python38 作为我的默认值,使用 Python35 作为 TensorFlow,直到他们为 Python38 发布它。 If you wish to use the "non-default" Python, just invoke with the full path of the python.exe (or create a shortcut/batch file for it).如果您希望使用“非默认”Python,只需使用 python.exe 的完整路径调用(或为其创建快捷方式/批处理文件)。 Python then will take care of using the correct Python libs for that version.然后 Python 将负责为该版本使用正确的 Python 库。

在 Linux 上使用 Python 3.8.2(默认,2020 年 3 月 5 日,18:58:42)[GCC]

pip3 install --upgrade tf-nightly

Python Versions 3.5 - 3.8 are supported now.现在支持 Python 版本 3.5 - 3.8。

You can verify on this page: https://www.tensorflow.org/install/pip您可以在此页面上进行验证: https : //www.tensorflow.org/install/pip

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

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