Bil*_*l B 6 python pyinstaller tensorflow
我已经使用 tensorflow 构建了一个 python 脚本,现在我正在尝试将其转换为 .exe 文件,但遇到了问题。使用 pyinstaller 并从命令提示符运行程序后,我收到以下错误:
File "site-packages\tensorflow_core\python\pywrap_tensorflow.py", line 25, in <module> ModuleNotFoundError: No module named 'tensorflow.python.platform'
Run Code Online (Sandbox Code Playgroud)
我试过 --hidden-import tensorflow.python.platform 但它似乎没有修复任何东西。(该程序在解释器中运行得很好)您的帮助将不胜感激。
Leg*_*ooj 17
编辑:最新版本的 PyInstaller (4.0+) 现在包括对tensorflow
开箱即用的支持。
创建这样的目录结构:
- main.py # Your code goes here - don't bother actually naming you file this
- hooks
- hook-tensorflow.py
Run Code Online (Sandbox Code Playgroud)
将以下内容复制到hook-tensorflow.py
:
- main.py # Your code goes here - don't bother actually naming you file this
- hooks
- hook-tensorflow.py
Run Code Online (Sandbox Code Playgroud)
然后,在编译时,添加命令行选项--additional-hooks-dir=hooks
。
如果您遇到更多未找到的错误,只需将完整的导入名称添加到packages
列表中即可。
PS - 对我来说,main.py
简直就是from tensorflow import *
归档时间: |
|
查看次数: |
3838 次 |
最近记录: |