所以我在64位Windows 7上运行,并使用Pip和PyWin32设置Pyinstaller.我有python 2.7.
我用这段代码制作了一个简单的hello world程序
print "hello world!"
Run Code Online (Sandbox Code Playgroud)
我将该文件放在与PyInstaller相同的目录中,并在命令提示符下运行此代码
pyinstaller.py helloWorld.py
Run Code Online (Sandbox Code Playgroud)
然而,当我尝试时,我收到此错误消息:
Error loading Python DLL: C:\PROGRA~1\PYINST~1.1\build\HELLOW~1\python27.dll (error code 126)
Run Code Online (Sandbox Code Playgroud)
我做错了什么,如何解决这个问题?
我是编程新手。我用python写了一个小程序,并用.exe文件将其转换为.exe文件pyinstaller。现在,当我尝试打开 .exe 文件时,会出现黑屏并立即关闭。我能够得到一个截图:
我看到了一个解决方案,比如input()在代码末尾添加,但它也不起作用。我的代码:
import random
print("Hello, what is your name?")
name = str(input())
print("Well, " + name + ", I think of a number between 1 and 1000. Can you guess this number in 10 chances?")
number = random.randint(1, 1001)
for guessTaken in range(1, 11):
print("Take a guess")
guess = int(input())
if guess > number:
print("The number you think is too high")
elif guess < number:
print("The number you think is too low")
else:
break …Run Code Online (Sandbox Code Playgroud) 我正在尝试打包我编写的 python 程序/脚本(pastebin 链接),其中包含使用 tkinter 模块的 GUI。我决定使用 Pyinstaller,据他们说它支持 Python 3.7。
目前,尝试运行 pyinstaller 在实际打包时似乎不会产生任何问题。在我尝试运行可执行文件之后,它失败了。一个我生成可执行文件的一个文件变体,它只是打开一个命令提示符并挂起。当我执行非一个文件命令时,它会立即打开和关闭,但会给出错误输出,由于关闭速度太快,我看不到该输出。我直接在 cmd 中打开了可执行文件来解决这个问题,它给了我这个错误:
C:\Users\mqian\Desktop\CGIProject\autoprimercode\windowsversion\build\windowsaut
oprimer>windowsautoprimer.exe
Error loading Python DLL 'C:\Users\mqian\Desktop\CGIProject\autoprimercode\windo
wsversion\build\windowsautoprimer\python37.dll'.
LoadLibrary: The specified module could not be found.
Run Code Online (Sandbox Code Playgroud)
我不知道它是否应该在这个文件夹中寻找 python37.dll,但是,我有一个好主意,将 dll 从 python 目录复制到跟踪指定的一个(显然它不应该有变成那样)。现在我得到的错误是这样的:
C:\Users\mqian\Desktop\CGIProject\autoprimercode\windowsversion\build\windowsaut
oprimer>windowsautoprimer.exe
Traceback (most recent call last):
File "site-packages\PyInstaller\loader\rthooks\pyi_rth__tkinter.py", line 28,
in <module>
FileNotFoundError: Tcl data directory "C:\Users\mqian\Desktop\CGIProject\autopri
mercode\windowsversion\build\windowsautoprimer\tcl" not found.
[6600] Failed to execute script pyi_rth__tkinter
Run Code Online (Sandbox Code Playgroud)
无休止的谷歌搜索并没有产生任何具体的结果。以下是一些我认为可能会有所帮助的相关链接。
https://github.com/pyinstaller/pyinstaller/issues/2149
https://www.xoolive.org/2015/09/09/issues-on-loading-dlls-with-pyinstaller.html
PyInstaller:“没有名为 Tkinter 的模块”
https://github.com/pyinstaller/pyinstaller/issues/2495
为pyinstaller加载python27.dll错误时出错
这是我拥有的规范文件:
# -*- mode: python -*- …Run Code Online (Sandbox Code Playgroud)