pyinstaller .exe 找不到“dateutil.tz.__init__.tz”
Posted
技术标签:
【中文标题】pyinstaller .exe 找不到“dateutil.tz.__init__.tz”【英文标题】:pyinstaller .exe cannot find 'dateutil.tz.__init__.tz' 【发布时间】:2016-06-24 02:19:58 【问题描述】:这是我第一次创建 .exe(或任何包)。虽然我根据the kivy-manual 成功创建了kivy-touchtracer 演示的exe 文件。 我使用相同的方法从我的 kivy-app 创建一个 .exe。它假设只在 Windows 上运行(第一个里程碑)。非 exe 版本按我的意愿运行。我可以设法创建一个 .exe 文件,但不知何故它没有运行。基本上程序应该收集一些数据,“计算一下”给定的数据,创建一些图(matplotlib)并创建一个报告-pdf (报告实验室)。 我已经试过了:
将 dateutils 从 python/Lib/sitepackages/dateutil 复制到创建的 dist 目录中。 (reportlab 提供了帮助) 将 dateutil/tz/init 中的“from .tz import *”行修改为“from tz import *”(删除点)它们看起来毫无用处......
如何运行我的 exe?我错过了什么? (Matplotlib 在 pyinstaller 的supported-package 列表中。)
操作系统:Win7 Python:3.4
我的 cal.spec 文件:
# -*- mode: python -*-
from kivy.deps import sdl2, glew
block_cipher = None
a = Analysis(['C:\\EZS-2G\\main.py'],
pathex=['C:\\EZS-2G\\calApp'],
binaries=None,
datas=None,
hiddenimports=['cycler','pyparsing','setuptools','tkinter','PyPDF2','jinja2','sqlite3','markupsafe','PIL','tornado','pytz','dateutil','reportlab','numpy','matplotlib'],
hookspath=[],
runtime_hooks=[],
excludes=[],
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher)
pyz = PYZ(a.pure, a.zipped_data,
cipher=block_cipher)
exe = EXE(pyz,
a.scripts,
exclude_binaries=True,
name='Cal',
debug=False,
strip=False,
upx=True,
console=True )
coll = COLLECT(exe, Tree('C:\\EZS-2G\\'),
a.binaries,
a.zipfiles,
a.datas,
*[Tree(p) for p in (sdl2.dep_bins + glew.dep_bins)],
strip=False,
upx=True,
name='Cal')
这是我的 .kivy/log.txt 结果:
[INFO ] Logger: Record log in C:\Users\kalibrierlabor\.kivy\logs\kivy_16-03-09_74.txt
[INFO ] Kivy: v1.9.1
[INFO ] Python: v3.4.4 (v3.4.4:737efcadf5a6, Dec 20 2015, 20:20:57) [MSC v.1600 64 bit (AMD64)]
[INFO ] Factory: 179 symbols loaded
[INFO ] Image: Providers: img_tex, img_dds, img_gif, img_sdl2, img_pil (img_ffpyplayer ignored)
[INFO ] OSC: using <thread> for socket
[INFO ] Window: Provider: sdl2
[INFO ] GL: GLEW initialization succeeded
[INFO ] GL: OpenGL version <b'3.3.0'>
[INFO ] GL: OpenGL vendor <b'NVIDIA Corporation'>
[INFO ] GL: OpenGL renderer <b'GeForce 210/PCIe/SSE2'>
[INFO ] GL: OpenGL parsed version: 3, 3
[INFO ] GL: Shading version <b'3.30 NVIDIA via Cg compiler'>
[INFO ] GL: Texture max size <8192>
[INFO ] GL: Texture max units <32>
[INFO ] Window: auto add sdl2 input provider
[INFO ] Window: virtual keyboard not allowed, single mode, not docked
[INFO ] Text: Provider: sdl2
[WARNING ] stderr: Traceback (most recent call last):
[WARNING ] stderr: File "<string>", line 58, in <module>
[WARNING ] stderr: File "C:\EZS-2G\CETAcalApp\dist\CETA-Cal\cls\plotting.py", line 5, in <module>
[WARNING ] stderr: import matplotlib.pyplot as plt
[WARNING ] stderr: File "C:\Python34\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 389, in load_module
[WARNING ] stderr: exec(bytecode, module.__dict__)
[WARNING ] stderr: File "C:\Python34\lib\site-packages\matplotlib\pyplot.py", line 36, in <module>
[WARNING ] stderr: from matplotlib.figure import Figure, figaspect
[WARNING ] stderr: File "C:\Python34\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 389, in load_module
[WARNING ] stderr: exec(bytecode, module.__dict__)
[WARNING ] stderr: File "C:\Python34\lib\site-packages\matplotlib\figure.py", line 40, in <module>
[WARNING ] stderr: from matplotlib.axes import Axes, SubplotBase, subplot_class_factory
[WARNING ] stderr: File "C:\Python34\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 389, in load_module
[WARNING ] stderr: exec(bytecode, module.__dict__)
[WARNING ] stderr: File "C:\Python34\lib\site-packages\matplotlib\axes\__init__.py", line 4, in <module>
[WARNING ] stderr: from ._subplots import *
[WARNING ] stderr: File "C:\Python34\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 389, in load_module
[WARNING ] stderr: exec(bytecode, module.__dict__)
[WARNING ] stderr: File "C:\Python34\lib\site-packages\matplotlib\axes\_subplots.py", line 10, in <module>
[WARNING ] stderr: from matplotlib.axes._axes import Axes
[WARNING ] stderr: File "C:\Python34\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 389, in load_module
[WARNING ] stderr: exec(bytecode, module.__dict__)
[WARNING ] stderr: File "C:\Python34\lib\site-packages\matplotlib\axes\_axes.py", line 22, in <module>
[WARNING ] stderr: import matplotlib.dates as _ # <-registers a date unit converter
[WARNING ] stderr: File "C:\Python34\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 389, in load_module
[WARNING ] stderr: exec(bytecode, module.__dict__)
[WARNING ] stderr: File "C:\Python34\lib\site-packages\matplotlib\dates.py", line 130, in <module>
[WARNING ] stderr: import dateutil.parser
[WARNING ] stderr: File "C:\Python34\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 389, in load_module
[WARNING ] stderr: exec(bytecode, module.__dict__)
[WARNING ] stderr: File "C:\Python34\lib\site-packages\dateutil\parser.py", line 43, in <module>
[WARNING ] stderr: from . import tz
[WARNING ] stderr: File "C:\Python34\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 389, in load_module
[WARNING ] stderr: exec(bytecode, module.__dict__)
[WARNING ] stderr: File "C:\Python34\lib\site-packages\dateutil\tz\__init__.py", line 1, in <module>
[WARNING ] stderr: from .tz import *
[WARNING ] stderr: File "C:\Python34\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 389, in load_module
[WARNING ] stderr: exec(bytecode, module.__dict__)
[WARNING ] stderr: File "C:\Python34\lib\site-packages\dateutil\tz\tz.py", line 17, in <module>
[WARNING ] stderr: from .__init__ import tzname_in_python2
[WARNING ] stderr: File "C:\Python34\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 389, in load_module
[WARNING ] stderr: exec(bytecode, module.__dict__)
[WARNING ] stderr: File "C:\Python34\lib\site-packages\dateutil\tz\__init__.py", line 1, in <module>
[WARNING ] stderr: from .tz import *
[WARNING ] stderr: ImportError: No module named 'dateutil.tz.__init__.tz'
【问题讨论】:
【参考方案1】:我遇到了同样的问题(也在 Windows 7 和 Python 3.4 以及 python-dateutil 2.5 版上)。我做了一些阅读,例如在https://github.com/dateutil/dateutil/pull/202#issuecomment-192352290。像你一样,我尝试对 dateutil 包进行一些修改,但最后我只是用 pip 将包恢复到以前的版本,即“pip install python-dateutil==2.4.2”,这为我解决了这个问题。
【讨论】:
谢谢,这对我也有帮助【参考方案2】:我有类似的问题。由于一切正常,我找到了一种解决方法:
import warnings
warnings.filterwarnings("ignore", category=UserWarning)
【讨论】:
以上是关于pyinstaller .exe 找不到“dateutil.tz.__init__.tz”的主要内容,如果未能解决你的问题,请参考以下文章
Pyinstaller:找不到 PyQT5 Web 应用程序的 QtWebEngineProcess.exe
Pyinstaller Packed EXE 无法在其他 PC 上运行脚本。说:Qt5Core,找不到dll
使用 Pyinstaller 创建 .exe 错误:找不到程序集 amd64_Microsoft.VC90.CRT_1fc8b3b9a1e18e3b_9.0.21022.8_none