简体   繁体   English

在 Path 上安装 Python 3.9 时安装 Tensorflow?

[英]Installing Tensorflow when Python 3.9 is installed on Path?

2 Versions of Python 3.9 and 3.8.6 are installed on Win 10. I Also want Tensorflow installed. Win 10 上安装了 Python 3.9 和 3.8.6 的 2 个版本。我还想安装 Tensorflow。 But Pip recognises only Py 3.9 and hence does not installs tf locally.但是 Pip 只识别 Py 3.9,因此不会在本地安装 tf。 Is there a way out for this.有没有办法解决这个问题。

试试这个命令

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

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

这适用于我的 python 3.9

以下命令应该适用于 python 版本 3.9: python -m pip install --upgrade https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-1.12.0-py3-none-any.whl

For dealing with multiple Python Versions it is highly recommended to use virtual environments.为了处理多个 Python 版本,强烈建议使用虚拟环境。 It makes live much easier.它使生活变得更加轻松。 For a detailed guide how to set them up read this: https://www.freecodecamp.org/news/manage-multiple-python-versions-and-virtual-environments-venv-pyenv-pyvenv-a29fb00c296f/有关如何设置它们的详细指南,请阅读: https ://www.freecodecamp.org/news/manage-multiple-python-versions-and-virtual-environments-venv-pyenv-pyvenv-a29fb00c296f/

This worked for me:这对我有用:

python3.8 -m pip install tensorflow

I think pip uses the latest python version, so you have to tell pip to install with python3.8 or use the beta version of tensorflow:我认为 pip 使用最新的 python 版本,所以你必须告诉 pip 使用 python3.8 安装或使用 tensorflow 的 beta 版本:

pip install tf-nightly

Change you're Environment variable from python 3.9 to python 3.8.6 .将您的环境变量从python 3.9更改为python 3.8.6

1.search for environment variables in your pc see the pic --->. 1.在你的电脑中搜索environment variables看图片--->。 Environment variables环境变量

2.Now select environment variables option see pic --->. 2.现在选择environment variables选项见图片--->。 click on option点击选项

  1. Now edit the path of wanted python see pic --->.现在edit想要的python的路径参见图片--->。 Edit编辑

Your system is defaulting to python 3.9 because it is higher up in the system path list, so it is seen first.您的系统默认为 python 3.9,因为它在系统路径列表中较高,所以首先看到它。 search for environment variable in windows then click on environment variable .在 windows 中搜索环境变量,然后单击环境变量 Then under system variable , search for path and then move the python3.8 higher up than python3.9.然后在系统变量下,搜索路径,然后将python3.8移动到高于 python3.9 的位置。 Your system will now see 3.8 as default.您的系统现在将默认设置为 3.8。

I did two things to make it work.我做了两件事让它发挥作用。

  1. After pip install tensorflow, restarted my VS Code在 pip install tensorflow 之后,重新启动了我的 VS Code
  2. Change the interpreter from 3.9 to 3.7, so it started installing ipython relevant packages and then changed it back to 3.9.将解释器从 3.9 更改为 3.7,因此它开始安装 ipython 相关包,然后将其更改回 3.9。

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

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