【问题标题】:Jupyter Notebook doesn't detect Python 3.7Jupyter Notebook 未检测到 Python 3.7
【发布时间】:2022-08-06 00:16:57
【问题描述】:

我目前正在尝试安装 Tensorflow 1.15.0,但我当前的 Python 版本是 3.8.10,它不支持该版本的 Tensorflow。我使用以下命令安装了Python3.7

sudo apt install python3.7

并使用了来自 post 的这些命令:

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

但是当我跑步时

!python3 --version

它仍然显示 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

我不愿意卸载 Python 3.8,因为上次我这样做完全破坏了我的操作系统并迫使我重新安装整个东西。我该如何解决这个问题?我在 Ubuntu 20.04

  • 也许你应该在 Python 3.7 中安装 jupyter 和 - pip3.7 install jupyter - 使用 python3.7 -m jupyter 运行它。
  • @omar 我按照教程进行操作,但现在 jupyter 在尝试导入任何模块时给了我这个错误ModuleNotFoundError: No module named...,尽管我已经安装了这些模块。
  • 如果您安装不同版本的所有库,新版本最多不显示,您应该下载整个库

标签: python tensorflow jupyter-notebook


【解决方案1】:

您无需从系统中卸载 Python 3.8。如果您只是简单地按照this 链接中提到的步骤,您可以在您的系统中成功安装TensorFlow 1.15Python 3.7

或者您可以按照以下步骤操作:

  1. Download 并安装 Anaconda

    (如果您的系统中已经安装,请忽略此步骤)

    1. 使用 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. 安装张量流

    点安装张量流==1.15

    1. 打开 jupyter 笔记本在相同的虚拟环境(tf)中并运行以下命令:
    import tensorflow as tf
    tf.__version__     #to check installed tensorflow version
    !python --version  #to check installed python version
    

    也可以创建虚拟环境,通过安装pythonTensorFlow蟒蛇导航器.

    为此,请打开蟒蛇导航器并转到:

    环境 -> 创建 -> Vir_env 名称 -> 选择 Python -> 在同一个 Vir_env 中安装并启动 jupyter -> 使用代码安装所需的 tensorflow 版本 - !pip install tensorflow==<version>

    同样,您可以创建多个虚拟环境,并可以在同一个 Anaconda Navigator 中安装不同兼容版本的 python 和 tensorflow。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-12-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-02-12
    相关资源
    最近更新 更多