python - 使用 pip 和诗歌与 python 3.10.4 安装 TensorFlow 2.8.0 错误

标签 python tensorflow pip python-poetry

编辑 2:已解决

我多次尝试以不同的方式安装 TensorFlow:

  • 尝试在 Windows(10 和 11)、WSL2.0 和 Ubuntu 操作系统中安装它。
  • 尝试在 4 台不同的计算机上安装它,其中一台配备 i7-11800H、RTX3060 和 16GB RAM。
  • 尝试使用 pip 和诗歌安装它。
  • 尝试使用 CML(Powershell 和 Ubuntu)和 PyCharm 包管理器安装它。
  • 尝试过 venv 和 Poetry shell 环境。

每次都会出现以下结果(例如输入 poetry add tensorflowpip install tensorflow 后)

Updating dependencies
Resolving dependencies...

  SolverProblemError

  The current project's Python requirement (>=3.10,<4.0) is not compatible with some of the required packages Python requirement:
    - tensorflow-io-gcs-filesystem requires Python >=3.7, <3.11, so it will not be satisfied for Python >=3.11,<4.0
    - tensorflow-io-gcs-filesystem requires Python >=3.7, <3.11, so it will not be satisfied for Python >=3.11,<4.0
    - tensorflow-io-gcs-filesystem requires Python >=3.7, <3.11, so it will not be satisfied for Python >=3.11,<4.0

  Because no versions of tensorflow-io-gcs-filesystem match >0.23.1,<0.24.0 || >0.24.0,<0.25.0 || >0.25.0
   and tensorflow-io-gcs-filesystem (0.23.1) requires Python >=3.7, <3.11, tensorflow-io-gcs-filesystem is forbidden.
  And because tensorflow-io-gcs-filesystem (0.24.0) requires Python >=3.7, <3.11
   and tensorflow-io-gcs-filesystem (0.25.0) requires Python >=3.7, <3.11, tensorflow-io-gcs-filesystem is forbidden.
  Because no versions of tensorflow match >2.8.0,<3.0.0
   and tensorflow (2.8.0) depends on tensorflow-io-gcs-filesystem (>=0.23.1), tensorflow (>=2.8.0,<3.0.0) requires tensorflow-io-gcs-filesystem (>=0.23.1).
  Thus, tensorflow is forbidden.
  So, because pythonproject4 depends on tensorflow (^2.8.0), version solving failed.

  at ~\AppData\Roaming\Python\Python310\site-packages\poetry\puzzle\solver.py:241 in _solve
      237│             packages = result.packages
      238│         except OverrideNeeded as e:
      239│             return self.solve_in_compatibility_mode(e.overrides, use_latest=use_latest)
      240│         except SolveFailure as e:
    → 241│             raise SolverProblemError(e)
      242│
      243│         results = dict(
      244│             depth_first_search(
      245│                 PackageNode(self._package, packages), aggregate_package_nodes

  • Check your dependencies Python requirement: The Python requirement can be specified via the `python` or `markers` properties

    For tensorflow-io-gcs-filesystem, a possible solution would be to set the `python` property to ">=3.10,<3.11"
    For tensorflow-io-gcs-filesystem, a possible solution would be to set the `python` property to ">=3.10,<3.11"
    For tensorflow-io-gcs-filesystem, a possible solution would be to set the `python` property to ">=3.10,<3.11"

    https://python-poetry.org/docs/dependency-specification/#python-restricted-dependencies,
    https://python-poetry.org/docs/dependency-specification/#using-environment-markers

在Python 3.9上安装TF 2.8没有问题 但我的问题是:既然我有Python 3.10.4,为什么会发生以下错误

tensorflow-io-gcs-filesystem requires Python >=3.7, <3.11, so it will not be satisfied for Python >=3.11,<4.0


编辑:

当我手动编辑 .toml 文件中的依赖项时,如下所示:

[tool.poetry.dependencies]

python = ">=3.10,<3.11"

它安装了大部分软件包,然后在某些方面失败并出现以下错误:

Using version ^2.8.0 for tensorflow

Updating dependencies
Resolving dependencies...

Writing lock file

Package operations: 34 installs, 0 updates, 0 removals

  • Installing certifi (2021.10.8)
  • Installing charset-normalizer (2.0.12)
  • Installing idna (3.3)
  • Installing pyasn1 (0.4.8)
  • Installing urllib3 (1.26.9)
  • Installing cachetools (5.0.0)
  • Installing oauthlib (3.2.0)
  • Installing pyasn1-modules (0.2.8)
  • Installing requests (2.27.1)
  • Installing rsa (4.8)
  • Installing google-auth (2.6.6)
  • Installing requests-oauthlib (1.3.1)
  • Installing google-auth-oauthlib (0.4.6)
  • Installing grpcio (1.46.0)
  • Installing markdown (3.3.7)
  • Installing tensorboard-data-server (0.6.1)
  • Installing tensorboard-plugin-wit (1.8.1)
  • Installing werkzeug (2.1.2)
  • Installing astunparse (1.6.3)
  • Installing flatbuffers (2.0)
  • Installing gast (0.5.3)
  • Installing google-pasta (0.2.0)
  • Installing h5py (3.6.0)
  • Installing keras (2.8.0)
  • Installing keras-preprocessing (1.1.2)
  • Installing libclang (14.0.1)
  • Installing opt-einsum (3.3.0)
  • Installing tensorboard (2.8.0)
  • Installing tensorflow-io-gcs-filesystem (0.25.0)
  • Installing termcolor (1.1.0)
  • Installing tf-estimator-nightly (2.8.0.dev2021122109)
  • Installing typing-extensions (4.2.0)
  • Installing wrapt (1.14.1)
  • Installing tensorflow (2.8.0)

  EnvCommandError

  Command C:\Users\majda\AppData\Local\pypoetry\Cache\virtualenvs\pythonproject3-pEOchWpC-py3.10\Scripts\pip.exe install --no-deps C:\Users\majda\AppData\Local\pypoetry\Cache\artifacts\9b\54\38\c69dfa96cba7e69e543db60e6f1bc9060f68c5cf51bdb1796760b5bfcc\tensorflow-2.8.0-cp310-cp310-win_amd64.whl errored with the following return code 1, and output: 
  Processing c:\users\majda\appdata\local\pypoetry\cache\artifacts\9b\54\38\c69dfa96cba7e69e543db60e6f1bc9060f68c5cf51bdb1796760b5bfcc\tensorflow-2.8.0-cp310-cp310-win_amd64.whl
  Installing collected packages: tensorflow
  ERROR: Could not install packages due to an OSError: [Errno 2] No such file or directory: 'C:\\Users\\majda\\AppData\\Local\\pypoetry\\Cache\\virtualenvs\\pythonproject3-pEOchWpC-py3.10\\Lib\\site-packages\\tensorflow\\include\\external\\cudnn_frontend_archive\\_virtual_includes\\cudnn_frontend\\third_party\\cudnn_frontend\\include\\cudnn_frontend_EngineConfigGenerator.h'
  HINT: This error might have occurred since this system does not have Windows Long Path support enabled. You can find information on how to enable this at https://pip.pypa.io/warnings/enable-long-paths
  
  

  at ~\AppData\Roaming\Python\Python310\site-packages\poetry\utils\env.py:1195 in _run


Failed to add packages, reverting the pyproject.toml file to its original content.

编辑2:

如果您使用 Ubuntu,则不会发生第二个错误。但如果您使用 Windows,则根据 microfocus 解决该错误是:

  1. 单击 Window 键并键入 gpedit.msc,然后按 Enter 键。这将启动本地组策略编辑器。

  2. 导航到本地计算机策略 > 计算机配置 > 管理模板 > 系统 > 文件系统。

  3. 双击“启用 NTFS 长路径”。

  4. 选择“启用”,然后单击“确定”

最佳答案

使用诗歌时,在 pyproject.toml 中手动编辑:

[tool.poetry.dependencies]
python = ">=3.10,<3.11"

关于python - 使用 pip 和诗歌与 python 3.10.4 安装 TensorFlow 2.8.0 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/72154617/

相关文章:

python - 似乎无法使用 pip 更新到 sklearn 0.19?

python - 将 .overrideColor 值分配给 Maya 中的按钮

python - Tkinter 实时量表

python - 你如何在 python 中制作排行榜?

python - 检查输入 : expected conv2d_1_input to have shape (3, 32, 32) 时出错,但得到形状为 (32, 32, 3) 的数组

python - `python -m pip install` 是做什么的?

python - Anaconda 客户端 CLI 已安装,但未找到 anaconda 命令

python - 找到文本文件中最长的单词和最大的数字

python - 无法获取Tensorflow的卷积算法

tensorflow - 如何在占位符中为非确定性数组大小设置形状