我有几个py文件(带有多个窗口的PyQt5小应用程序),我想编译成1个exe文件。 我试图通过以下命令使用pyinstaller:
pyinstaller --onefile main.py
但有时我会收到此错误消息:
File "d:\python\lib\site-packages\PyInstaller\building\build_main.py", line 244, in __init__
self.__postinit__()
File "d:\python\lib\site-packages\PyInstaller\building\datastruct.py", line 160, in __postinit__
self.assemble()
File "d:\python\lib\site-packages\PyInstaller\building\build_main.py", line 422, in assemble
self.graph.process_post_graph_hooks()
File "d:\python\lib\site-packages\PyInstaller\depend\analysis.py", line 311, in process_post_graph_hooks
module_hook.post_graph()
File "d:\python\lib\site-packages\PyInstaller\depend\imphook.py", line 417, in post_graph
self._load_hook_module()
File "d:\python\lib\site-packages\PyInstaller\depend\imphook.py", line 383, in _load_hook_module
self._hook_module = importlib_load_source(
File "d:\python\lib\site-packages\PyInstaller\compat.py", line 797, in importlib_load_source
return mod_loader.load_module()
File "<frozen importlib._bootstrap_external>", line 462, in _check_name_wrapper
File "<frozen importlib._bootstrap_external>", line 962, in load_module
File "<frozen importlib._bootstrap_external>", line 787, in load_module
File "<frozen importlib._bootstrap>", line 265, in _load_module_shim
File "<frozen importlib._bootstrap>", line 702, in _load
File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 783, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "d:\python\lib\site-packages\PyInstaller\hooks\hook-sqlalchemy.py", line 30, in <module>
dialects = eval(dialects.strip())
File "<string>", line 0
^
SyntaxError: unexpected EOF while parsing
意外的EOF:通常表示存在开环,或者某处缺少括号。 但是我尝试到处寻找它,但没有找到它,而且我的代码也可以从PyCharm正常运行。 所以我想知道这个错误是否确实存在,还是从pyinstaller一起编译许多py文件时只是一个错误? 任何想法? 非常感谢您的帮助!
输入后...
import sqlalchemy.dialects
print(sqlalchemy.dialects.__all__)
我明白了:
Traceback (most recent call last):
File "C:/Users/PC/Desktop/mesprojets/nouvo/main.py", line 5, in <module>
import sqlalchemy.dialects
File "D:\PYTHON\lib\site-packages\sqlalchemy\__init__.py", line 12, in <module>
from sqlalchemy.sql import (
File "D:\PYTHON\lib\site-packages\sqlalchemy\sql\__init__.py", line 7, in <module>
from sqlalchemy.sql.expression import (
File "D:\PYTHON\lib\site-packages\sqlalchemy\sql\expression.py", line 32, in <module>
from sqlalchemy import util, exc
File "D:\PYTHON\lib\site-packages\sqlalchemy\util\__init__.py", line 7, in <module>
from .compat import callable, cmp, reduce, defaultdict, py25_dict, \
File "D:\PYTHON\lib\site-packages\sqlalchemy\util\compat.py", line 202, in <module>
time_func = time.clock
AttributeError: module 'time' has no attribute 'clock'
Process finished with exit code 1