oma*_*881 3 pyinstaller python-3.6
我正在尝试使用构建选项制作 Tkinter GUI 模块,以便在用户输入一些输入后构建 Exes,我不希望他安装 python 和 pyinstaller 以便能够将代码编译为 Exe。
使用 Python 3.6.0
我制作了 2 个 python 脚本,名字分别是 compiler.py 和其他 hello.py hello.pyprint("Hello World")
编译器.py
import PyInstaller.__main__
import ctypes
import win32ctypes
from win32ctypes import pywin32
from win32ctypes.pywin32 import pywintypes
import os
def compiling():
PyInstaller.__main__.run([
# '--name=%s' % package_name,
'--onefile',
'--windowed',
# '--add-binary=%s' % os.path.join('resource', 'path', '*.png'),
# '--add-data=%s' % os.path.join('resource', 'path', '*.txt'),
# '--icon=%s' % os.path.join('resource', 'path', 'icon.ico'),
os.path.join('hello.py'), # my_package is a Directory
# '--version-file=%s' % os.path.join('assembly.txt'),
])
compiling()
Run Code Online (Sandbox Code Playgroud)
当我尝试使用 pyinstaller 编译 compiler.py 时,它使用 -->pyinstaller --onefile --console compiler.py 成功编译
但是当我尝试运行 exe 时它会抛出
PyInstaller cannot check for assembly dependencies.
Please install pywin32-ctypes.
pip install pywin32-ctypes
Run Code Online (Sandbox Code Playgroud)
我尝试过什么?1-i 成功安装了 pywin32-ctypes 2-尝试使用 pyinstaller 3-cx-freeze 和 nuitka 以外的不同替代方法编译 compiler.py,当我在编译后运行时,它们都抛出相同的错误。4- 尝试在其他机器上使用 Python 3.7.5 开始新的 抛出同样的错误我选择 pyinstaller 的原因是因为它可以构建 1 个 EXE
https://github.com/pyinstaller/pyinstaller/issues/3892
https://github.com/pyinstaller/pyinstaller/issues/3793
无法运行 PyInstaller - “请安装 PyWin32 或 pywin32-ctypes”
所有这些都失败了是我做错了什么还是 Pyinstaller 问题
小智 7
我有完全相同的问题。
对我来说,修复方法是编辑 Pyinstaller compat.py 文件中的几行。
导航到您的 python 目录 -> Lib -> site-packages -> Pyinstaller。
打开 compat.py 并查找以下内容:
if is_win:
try:
from win32ctypes.pywin32 import pywintypes # noqa: F401
from win32ctypes.pywin32 import win32api
except ImportError:
# This environment variable is set by seutp.py
# - It's not an error for pywin32 to not be installed at that point
if not os.environ.get('PYINSTALLER_NO_PYWIN32_FAILURE'):
raise SystemExit('PyInstaller cannot check for assembly dependencies.\n'
'Please install pywin32-ctypes.\n\n'
'pip install pywin32-ctypes\n')
Run Code Online (Sandbox Code Playgroud)
更改这两个导入语句以导入模块本身,而不是尝试从 win32ctypes.pywin32 中获取它们。
#from win32ctypes.pywin32 import pywintypes # noqa: F401
#from win32ctypes.pywin32 import win32api
import pywintypes
import win32api
Run Code Online (Sandbox Code Playgroud)
我希望这有帮助!
小智 5
一个老问题,但也许有人可能会面临同样的问题。我找到了一个解决方案,它对我有用。
安装此模块即可解决问题
pip install cffi
Run Code Online (Sandbox Code Playgroud)
安装后,我再次尝试构建。给出类似错误的警告。
Traceback (most recent call last):
File "<string>", line 2, in <module>
ModuleNotFoundError: No module named 'win32com'
Traceback (most recent call last):
File "<string>", line 2, in <module>
ModuleNotFoundError: No module named 'win32com'
Run Code Online (Sandbox Code Playgroud)
您可以通过安装 pywin32 来修复此警告
pip install pywin32
Run Code Online (Sandbox Code Playgroud)
我希望它能帮助别人。
| 归档时间: |
|
| 查看次数: |
2802 次 |
| 最近记录: |