V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
chiyeung524
V2EX  ›  Python

pyinstaller 打包 tensorflow2.1 时出现错误,求解

  •  
  •   chiyeung524 · 2020-10-24 02:46:20 +08:00 · 3101 次点击
    这是一个创建于 1490 天前的主题,其中的信息可能已经有所发展或是发生改变。
    环境如下
    python 版本:3.7.6
    tensorflow 版本:2.1.0
    pyinstaller 版本:4.0

    出现错误如下,自己检索了网友们的解决方案,看不懂,来求助一下大家

    打包时输出部分错误如下:

    92309 WARNING: Hidden import "tensorflow_core._api.v2.compat.v2.compat.v2.keras.preprocessing.sequence" not found!
    92309 WARNING: Hidden import "tensorflow_core._api.v2.compat.v2.estimator.export" not found!
    92966 WARNING: Hidden import "tensorflow_core._api.v2.compat.v2.compat.v1.keras.datasets.mnist" not found!
    93060 WARNING: Hidden import "tensorflow_core._api.v2.compat.v1.keras.initializers" not found!
    93388 WARNING: Hidden import "tensorflow_core._api.v2.compat.v1.keras.experimental" not found!
    93544 WARNING: Hidden import "tensorflow_core._api.v2.compat.v2.compat.v2.keras.wrappers.scikit_learn" not found!
    93544 WARNING: Hidden import "tensorflow_core._api.v2.compat.v2.compat.v2.keras.estimator" not found!
    93653 WARNING: Hidden import "tensorflow_core._api.v2.compat.v2.keras.applications" not found!
    93653 WARNING: Hidden import "tensorflow_core._api.v2.compat.v2.compat.v2.keras.layers.experimental" not found!
    93888 WARNING: Hidden import "tensorflow_core._api.v2.compat.v2.keras.datasets.fashion_mnist" not found!
    94091 WARNING: Hidden import "tensorflow_core._api.v2.compat.v1.keras.wrappers" not found!
    94091 WARNING: Hidden import "tensorflow_core._api.v2.compat.v1.keras" not found!

    130818 INFO: Import to be excluded not found: 'tensorflow.python._pywrap_tensorflow_internal'
    130818 INFO: Loading module hook 'hook-win32com.py' from 'c:\\users\\chiyeungleung\\anaconda3\\envs\\mhpy\\lib\\site-packages\\_pyinstaller_hooks_contrib\\hooks\\stdhooks'...
    130943 INFO: Loading module hook 'hook-distutils.py' from 'c:\\users\\chiyeungleung\\anaconda3\\envs\\mhpy\\lib\\site-packages\\PyInstaller\\hooks'...
    130943 INFO: Loading module hook 'hook-encodings.py' from 'c:\\users\\chiyeungleung\\anaconda3\\envs\\mhpy\\lib\\site-packages\\PyInstaller\\hooks'...
    131115 INFO: Loading module hook 'hook-lib2to3.py' from 'c:\\users\\chiyeungleung\\anaconda3\\envs\\mhpy\\lib\\site-packages\\PyInstaller\\hooks'...
    131194 INFO: Loading module hook 'hook-matplotlib.backends.py' from 'c:\\users\\chiyeungleung\\anaconda3\\envs\\mhpy\\lib\\site-packages\\PyInstaller\\hooks'...
    132446 INFO: Matplotlib backend "GTK3Agg": ignored
    backend Gtk3Agg requires cairo
    133087 INFO: Matplotlib backend "GTK3Cairo": ignored
    cairo backend requires that pycairo>=1.11.0 or cairocffiis installed
    133602 INFO: Matplotlib backend "MacOSX": ignored
    cannot import name '_macosx' from 'matplotlib.backends' (c:\users\chiyeungleung\anaconda3\envs\mhpy\lib\site-packages\matplotlib\backends\__init__.py)
    134165 INFO: Matplotlib backend "nbAgg": ignored
    No module named 'IPython'
    -c:12: MatplotlibDeprecationWarning:
    The matplotlib.backends.backend_qt4agg backend was deprecated in Matplotlib 3.3 and will be removed two minor releases later.
    134916 INFO: Matplotlib backend "Qt4Agg": added
    135465 INFO: Matplotlib backend "Qt4Cairo": ignored
    cairo backend requires that pycairo>=1.11.0 or cairocffiis installed
    136246 INFO: Matplotlib backend "Qt5Agg": added
    136761 INFO: Matplotlib backend "Qt5Cairo": ignored
    cairo backend requires that pycairo>=1.11.0 or cairocffiis installed
    138011 INFO: Matplotlib backend "TkAgg": added
    139136 INFO: Matplotlib backend "TkCairo": ignored
    cairo backend requires that pycairo>=1.11.0 or cairocffiis installed
    139745 INFO: Matplotlib backend "WebAgg": ignored
    Traceback (most recent call last):
    File "c:\users\chiyeungleung\anaconda3\envs\mhpy\lib\site-packages\matplotlib\backends\backend_webagg.py", line 27, in <module>
    import tornado
    ModuleNotFoundError: No module named 'tornado'

    The above exception was the direct cause of the following exception:

    Traceback (most recent call last):
    File "<string>", line 12, in <module>
    File "c:\users\chiyeungleung\anaconda3\envs\mhpy\lib\site-packages\matplotlib\backends\backend_webagg.py", line 29, in <module>
    raise RuntimeError("The WebAgg backend requires Tornado.") from err
    RuntimeError: The WebAgg backend requires Tornado.
    140562 INFO: Matplotlib backend "WX": ignored
    No module named 'wx'
    141168 INFO: Matplotlib backend "WXAgg": ignored
    No module named 'wx'
    141761 INFO: Matplotlib backend "WXCairo": ignored
    No module named 'wx'

    149983 INFO: Loading module hook 'hook-pkg_resources.py' from 'c:\\users\\chiyeungleung\\anaconda3\\envs\\mhpy\\lib\\site-packages\\PyInstaller\\hooks'...
    150940 WARNING: Hidden import "pkg_resources.py2_warn" not found!
    150940 WARNING: Hidden import "pkg_resources.markers" not found!
    2 条回复    2020-10-24 19:43:06 +08:00
    aristolochic
        1
    aristolochic  
       2020-10-24 15:42:03 +08:00
    百度 pyinstaller 的--hiddent-import 参数
    考虑到 tensorflow 复杂的多,建议进一步搜索 pyinstaller spec hook
    yucongo
        2
    yucongo  
       2020-10-24 19:43:06 +08:00
    你可以试试直接将找不到的库直接从 lib\site-pages 或 lib 里的库目录直接拷 dist\baoming 目录里,繁琐一点可是肯定可行,缺什么拷什么。最后可能比折腾 spec 或 hook 还省时间一些!
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   2726 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 30ms · UTC 12:11 · PVG 20:11 · LAX 04:11 · JFK 07:11
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.