chr*_*hrx 10 python tensorflow python-poetry
我有一个诗歌项目。我的环境是 Windows 机器上的 Conda 22.9.0,诗歌版本为 1.2.2:
\n这是我的 pyproject.toml 文件:
\n[tool.poetry]\nname = "myproject"\nversion = "0.1.0"\ndescription = ""\n\n[tool.poetry.dependencies]\n# REVIEW DEPENDENCIES\npython = ">=3.7,<3.11"\nnumpy = "*"\ntensorflow = "^2.8"\n\n[build-system]\nrequires = ["poetry>=0.12"]\nbuild-backend = "poetry.masonry.api"\n\n[tool.poetry.scripts]\nstart = "myproject.main:start"\nRun Code Online (Sandbox Code Playgroud)\nmyproject\\main.py 模块包含:
\nimport tensorflow as tf\n\ndef start():\n if tf.test.is_gpu_available():\n print("TensorFlow is using a GPU.")\n else:\n print("TensorFlow is NOT using a GPU.")\nRun Code Online (Sandbox Code Playgroud)\n如果我这样做poetry install,它似乎工作正常:
Creating virtualenv myproject in D:\\Projects\\myproject\\dev\\myproject-series-forecast\\.venv\nUpdating dependencies\nResolving dependencies...\n\nWriting lock file\n\nPackage operations: 41 installs, 0 updates, 0 removals\n\n\xe2\x80\xa2 Installing certifi (2022.12.7)\n\xe2\x80\xa2 Installing charset-normalizer (2.1.1)\n\xe2\x80\xa2 Installing idna (3.4)\n\xe2\x80\xa2 Installing pyasn1 (0.4.8)\n\xe2\x80\xa2 Installing urllib3 (1.26.13)\n\xe2\x80\xa2 Installing cachetools (5.2.0)\n\xe2\x80\xa2 Installing oauthlib (3.2.2)\n\xe2\x80\xa2 Installing rsa (4.9)\n\xe2\x80\xa2 Installing six (1.16.0)\n\xe2\x80\xa2 Installing zipp (3.11.0)\n\xe2\x80\xa2 Installing requests (2.28.1)\n\xe2\x80\xa2 Installing pyasn1-modules (0.2.8)\n\xe2\x80\xa2 Installing google-auth (2.15.0)\n\xe2\x80\xa2 Installing importlib-metadata (5.2.0)\n\xe2\x80\xa2 Installing requests-oauthlib (1.3.1)\n\xe2\x80\xa2 Installing markupsafe (2.1.1)\n\xe2\x80\xa2 Installing absl-py (1.3.0)\n\xe2\x80\xa2 Installing grpcio (1.51.1)\n\xe2\x80\xa2 Installing numpy (1.21.6)\n\xe2\x80\xa2 Installing tensorboard-data-server (0.6.1)\n\xe2\x80\xa2 Installing markdown (3.4.1)\n\xe2\x80\xa2 Installing tensorboard-plugin-wit (1.8.1)\n\xe2\x80\xa2 Installing protobuf (3.19.6)\n\xe2\x80\xa2 Installing werkzeug (2.2.2)\n\xe2\x80\xa2 Installing google-auth-oauthlib (0.4.6)\n\xe2\x80\xa2 Installing astunparse (1.6.3)\n\xe2\x80\xa2 Installing flatbuffers (22.12.6)\n\xe2\x80\xa2 Installing gast (0.4.0)\n\xe2\x80\xa2 Installing google-pasta (0.2.0)\n\xe2\x80\xa2 Installing h5py (3.7.0)\n\xe2\x80\xa2 Installing keras (2.11.0)\n\xe2\x80\xa2 Installing tensorflow-estimator (2.11.0)\n\xe2\x80\xa2 Installing packaging (22.0)\n\xe2\x80\xa2 Installing opt-einsum (3.3.0)\n\xe2\x80\xa2 Installing libclang (14.0.6)\n\xe2\x80\xa2 Installing tensorboard (2.11.0)\n\xe2\x80\xa2 Installing tensorflow-io-gcs-filesystem (0.29.0)\n\xe2\x80\xa2 Installing termcolor (2.1.1)\n\xe2\x80\xa2 Installing typing-extensions (4.4.0)\n\xe2\x80\xa2 Installing wrapt (1.14.1)\n\xe2\x80\xa2 Installing tensorflow (2.11.0)\n\nInstalling the current project: myproject (0.1.0)\nRun Code Online (Sandbox Code Playgroud)\n但是执行时poetry run start我在导入时出错
Traceback (most recent call last):\nFile "<string>", line 1, in <module>\nFile "D:\\Python\\Anaconda3\\lib\\importlib\\__init__.py", line 127, in import_module\n return _bootstrap._gcd_import(name[level:], package, level)\nFile "<frozen importlib._bootstrap>", line 1030, in _gcd_import\nFile "<frozen importlib._bootstrap>", line 1007, in _find_and_load\nFile "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked\nFile "<frozen importlib._bootstrap>", line 680, in _load_unlocked\nFile "<frozen importlib._bootstrap_external>", line 850, in exec_module\nFile "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed\nFile "D:\\Projects\\myproject\\dev\\myproject-series-forecast\\myproject\\main.py", line 3, in <module>\n import tensorflow as tf\nModuleNotFoundError: No module named 'tensorflow'\nRun Code Online (Sandbox Code Playgroud)\n
小智 7
对于处理错误消息的任何人:
Unable to find installation candidates for tensorflow-io-gcs-filesystem (0.32.0)
这是因为版本与您尝试安装的tensorflow版本不兼容(请参阅此处的兼容性)。例如,如果您尝试安装tensorflow 2.10.*,则需要在.toml 文件中显式定义tensorflow-io-gcs-filesystem 的适当版本(即tensorflow-io-gcs-filesystem = "0.27.0")。
然后继续下载tensorflow(即poetry add tensorflow@~2.10)
| 归档时间: |
|
| 查看次数: |
8561 次 |
| 最近记录: |