CLion找不到tensorflow.python模块

我有以下Python代码

import tensorflow

if __name__ == '__main__':
    print("Hi")

从系统命令行运行正常。在CLion 中从Python控制台 运行可以正常工作。
但是在CLion中作为运行配置运行会产生

/usr/bin/python3.7 /<path>/main.py
Traceback (most recent call last):
  File "/<path>/main.py",line 1,in <module>
    import tensorflow
  File "/usr/lib/python3.7/site-packages/tensorflow/__init__.py",line 98,in <module>
    from tensorflow_core import *
  File "/usr/lib/python3.7/site-packages/tensorflow_core/__init__.py",line 40,in <module>
    from tensorflow.python.tools import module_util as _module_util
ModuleNotFoundError: No module named 'tensorflow.python.tools'; 'tensorflow.python' is not a package

Process finished with exit code 1

我尝试使用venv Python解释器,以上输出使用系统解释器(/usr/bin/python3.7)。手动运行它,并让IDE调用/usr/bin/python3.7 /<path>/main.py,即仍然会出问题,这有什么区别?

我可以导入其他模块,例如numpy没问题。我以为tensorflow可能不在系统范围内可用,所以我尝试以本地用户身份运行CLion,但无济于事。 tensorflow甚至在CLion中的Python解释器设置下列出。好吧,它甚至可以找到tensorflow,而不是tensorflow.python。只需导入即可使用其他所有方式。

crediblebridge 回答:CLion找不到tensorflow.python模块

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/3050353.html

大家都在问