python - 我可以在 python 终端上导入 tensorflow,但是如果我尝试运行我的 py 文件,我不能
问题描述
当我在终端中使用 python 时;
pi@raspberrypi:~ $ python
Python 3.7.3 (default, Dec 20 2019, 18:57:59)
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow
2020-07-26 12:52:03.075590: E tensorflow/core/platform/hadoop/hadoop_file_system.cc:132] HadoopFileSystem load error: libhdfs.so: cannot open shared object file: No such file or directory
>>>
但我尝试运行我的 py 文件
pi@raspberrypi:~ $ sudo python /home/pi/tfdeneme.py
pygame 1.9.4.post1
Hello from the pygame community. https://www.pygame.org/contribute.html
Traceback (most recent call last):
File "/home/pi/tfdeneme.py", line 17, in <module>
import tensorflow
ModuleNotFoundError: No module named 'tensorflow'
我在我的 Windows 机器上使用 tensorflow 2.2.0,在树莓派 tensorflow 版本上 =
pi@raspberrypi:~ $ python
Python 3.7.3 (default, Dec 20 2019, 18:57:59)
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
2020-07-26 12:53:49.504578: E tensorflow/core/platform/hadoop/hadoop_file_system.cc:132] HadoopFileSystem load error: libhdfs.so: cannot open shared object file: No such file or directory
>>> tf.__version__
'1.14.0'
我应该怎么做才能运行我的 py 文件?
解决方案
我在 TF 2.2.0 和 python 3.7 上遇到问题,因此降级到 python 3.6,现在它似乎正在工作。请注意我在Mac上
推荐阅读
- python - scrapy - 重新启动 scrapoxy 实例?
- reactjs - Create-react-app:实验性语法“classProperties”当前未启用
- unit-testing - 如何修复“TypeError:window.location 不是函数”?
- user-interface - 如何将 Widget 注入自定义子 Widget 并使用子 Widgets 迭代索引?
- python - 从 os.system-Zabbix trapper 获取输出
- wordpress - Wordpress 缩略图图像模糊
- javascript - 通过向上滚动触发功能
- python - 如何在 Python 脚本中执行 .exe 程序?
- c++ - 为什么 Godbolt 生成的 asm 输出与我在 Visual Studio 中的实际 asm 代码不同?
- c# - 使用加密算法保护承载令牌