简体   繁体   English

Jupyter Notebook 未检测到 Python 3.7

[英]Jupyter Notebook doesn't detect Python 3.7

I am currently trying to install Tensorflow 1.15.0 , but my current Python version is 3.8.10 which doesn't support that version of Tensorflow .我目前正在尝试安装Tensorflow 1.15.0 ,但我当前的 Python 版本是 3.8.10 ,它不支持该版本的Tensorflow I installed Python3.7 using the following command:我使用以下命令安装了Python3.7

sudo apt install python3.7

And used these commands from this post :并使用了这篇文章中的这些命令:

pip3 install ipykernel --upgrade
python3 -m ipykernel install --user

But when I run但是当我跑步时

!python3 --version

it still shows 3.8.10 and Tensorflow 1.15.0 fails to install with the following error:它仍然显示 3.8.10 和Tensorflow 1.15.0无法安装并出现以下错误:

ERROR: Could not find a version that satisfies the requirement tensorflow-gpu==1.15.0 (from versions: 2.2.0, 2.2.1, 2.2.2, 2.2.3, 2.3.0, 2.3.1, 2.3.2, 2.3.3, 2.3.4, 2.4.0, 2.4.1, 2.4.2, 2.4.3, 2.4.4, 2.5.0, 2.5.1, 2.5.2, 2.5.3, 2.6.0, 2.6.1, 2.6.2, 2.6.3, 2.6.4, 2.6.5, 2.7.0rc0, 2.7.0rc1, 2.7.0, 2.7.1, 2.7.2, 2.7.3, 2.8.0rc0, 2.8.0rc1, 2.8.0, 2.8.1, 2.8.2, 2.9.0rc0, 2.9.0rc1, 2.9.0rc2, 2.9.0, 2.9.1)
ERROR: No matching distribution found for tensorflow-gpu==1.15.0

I am not willing to uninstall Python 3.8, because last time I did that it completely broke my OS and forced me to reinstall the entire thing.我不愿意卸载 Python 3.8,因为上次我这样做完全破坏了我的操作系统并迫使我重新安装整个东西。 How do I solve this issue?我该如何解决这个问题? I am on Ubuntu 20.04我在 Ubuntu 20.04

You need not to uninstall Python 3.8 from your system.您无需从系统中卸载Python 3.8 If you just simply follow the steps mentioned in this link, you can successfully install TensorFlow 1.15 with Python 3.7 in your system.如果您只是简单地按照链接中提到的步骤,您可以在您的系统中成功安装TensorFlow 1.15Python 3.7

Or you can follow the steps below:或者您可以按照以下步骤操作:

  1. Download and install Anaconda下载并安装 Anaconda

(Please ignore this step if it is already installed in your system) (如果您的系统中已经安装,请忽略此步骤)

  1. Create a virtual environment with Python (python=3.7)使用 Python (python=3.7) 创建虚拟环境
conda create --name tf python=3.7 conda deactivate #to deactivate the tf environment conda activate tf #to activate the tf environment
  1. Install tensorflow安装 tensorflow

pip install tensorflow==1.15 pip 安装张量流==1.15

  1. Open jupyter notebook in the same virtual environment (tf) and run below command:在同一虚拟环境 (tf) 中打开 jupyter notebook并运行以下命令:
 import tensorflow as tf tf.__version__ #to check installed tensorflow version !python --version #to check installed python version

You can also create a virtual environment and install python and TensorFlow through Anaconda Navigator .您还可以通过Anaconda Navigator创建虚拟环境并安装pythonTensorFlow

For this, Please open Anaconda Navigator and go to:为此,请打开Anaconda Navigator和 go 到:

Environments -> create -> Vir_env name -> select Python -> install and launch jupyter in the same Vir_env -> install required tensorflow version using code - !pip install tensorflow==<version>环境 -> 创建 -> Vir_env 名称 -> select Python -> 在同一个 Vir_env 中安装和启动 jupyter -> 安装所需的 Z2C39BC19B761AC36DC046245D1D47 FE 版本!pip install tensorflow==<version>

Likewise, you can create multiple virtual environments and can install different compatible versions of python and tensorflow inside the same Anaconda Navigator.同样,您可以创建多个虚拟环境,并可以在同一个 Anaconda Navigator 中安装不同兼容版本的 python 和 tensorflow。

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

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