Edit 2:解决了
我尝试用不同的方式安装TensorFlow很多次:
- 尝试在Windows(10和11),WSL2.0和Ubuntu操作系统中安装。
- 尝试在4台不同的计算机上安装它,其中一台有i7-11800H, RTX3060和16GB RAM。
- 尝试使用pip和poetry安装
- 尝试使用CML (Powershell和Ubuntu)和PyCharm包管理器安装。
- 为环境尝试venv和poetry shell。
每次(例如,在输入poetry add tensorflow
或pip 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 ~AppDataRoamingPythonPython310site-packagespoetrypuzzlesolver.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:UsersmajdaAppDataLocalpypoetryCachevirtualenvspythonproject3-pEOchWpC-py3.10Scriptspip.exe install --no-deps C:UsersmajdaAppDataLocalpypoetryCacheartifacts9b5438c69dfa96cba7e69e543db60e6f1bc9060f68c5cf51bdb1796760b5bfcctensorflow-2.8.0-cp310-cp310-win_amd64.whl errored with the following return code 1, and output:
Processing c:usersmajdaappdatalocalpypoetrycacheartifacts9b5438c69dfa96cba7e69e543db60e6f1bc9060f68c5cf51bdb1796760b5bfcctensorflow-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 ~AppDataRoamingPythonPython310site-packagespoetryutilsenv.py:1195 in _run
Failed to add packages, reverting the pyproject.toml file to its original content.
Edit 2:
如果你使用Ubuntu,第二个错误不会发生。但是如果你使用Windows根据microfocus这个错误的解决方案是:
单击窗口键并键入gpedit。msc,然后按Enter键。这将启动本地组策略编辑器。
导航到本地计算机策略>计算机配置>管理模板>系统比;文件系统。
双击启用NTFS长路径。
选择Enabled,然后点击OK
使用诗歌时,在pyproject.toml
中手动编辑:
[tool.poetry.dependencies]
python = ">=3.10,<3.11"