使用Poetry安装TensorFlow后Python提示ModuleNotFoundError的问题求助
Poetry安装TensorFlow后Python提示ModuleNotFoundError的问题求助
大家好,我碰到个棘手的问题:用Poetry(版本2.0.1)安装了TensorFlow的Python包,但在Python环境里完全识别不到,导入时直接抛出ModuleNotFoundError。有没有其他朋友也遇到过类似情况?求分享解决思路!
我执行的安装命令是:
C:\Users\username\Documents\folder>poetry add tensorflow
安装过程的系统反馈如下:
Using version ^2.18.0 for tensorflow
Updating dependencies
Resolving dependencies... (0.9s)Package operations: 18 installs, 0 updates, 0 removals
本次安装的包列表:
- Installing markupsafe (3.0.2)
- Installing grpcio (1.70.0)
- Installing markdown (3.7)
- Installing protobuf (5.29.3)
- Installing setuptools (75.8.0)
- Installing tensorboard-data-server (0.7.2)
- Installing werkzeug (3.1.3)
- Installing wheel (0.45.1)
- Installing astunparse (1.6.3)
- Installing gast (0.6.0)
- Installing libclang (18.1.1)
- Installing opt-einsum (3.4.0)
- Installing google-pasta (0.2.0)
- Installing flatbuffers (25.1.24)
- Installing termcolor (2.5.0)
- Installing tensorboard (2.18.0)
- Installing wrapt (1.17.2)
- Installing tensorflow (2.18.0)
Writing lock file
之后我用poetry run python进入Python交互环境,尝试导入TensorFlow就报错了:
Python 3.12.8 (tags/v3.12.8:2dc476b, Dec 3 2024, 19:30:04) [MSC v.1942 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import tensorflow Traceback (most recent call last): File "<stdin>", line 1, in <module> ModuleNotFoundError: No module named 'tensorflow'
明明安装日志显示TensorFlow已经装好了,怎么会找不到呢?有没有大佬能帮我排查下问题所在?
备注:内容来源于stack exchange,提问作者explorer
相关产品推荐
相关产品推荐

