I created a python application and used PyInstaller to convert it into .exe.
My problem is: I was playing around with the .exe files for practicing, And i changed the manifest name and the application doesn't work (indeed) but the wired thing is: when I re-named that manifest file to the original name. The application is still not working with the same error: '380 Ordinal not found'. And I also tried to uninstall the application and re-install it, but again still not working (BUT if I install it with a different name OR path the application will work fine).
I think it is something related to Temp files some of the settings are stored somewhere and in order to let my application work I need to clear these files (Am guessing).
So please could someone explain to me the cause of the problem and why it happened and how to resolve it?
Python 3.7,
Pyinstaller 4.5,
win 10
I found the solution: the problem happened because the manifest becomes tattooed into that executable name after the launch.
So modifying the modification date of the exe file will do the job and the application will works fine again.
Here is a python script that can fix this kind of problem:
import os
import time
import datetime
path = './/run_application//run_application.exe'
modified_ts = time.mktime(datetime.datetime.now().timetuple())
os.utime(path, (modified_ts, modified_ts))
print("Executable modification time has been updated.")
Here you can see the topic with more explanation https://github.com/pyinstaller/pyinstaller/issues/6223
Related
I have created a python script that I am attempting to turn into an application on mac so that I do not have to alway open the terminal. I am using Tkinter to create a window that the script runs on.
I run pyinstaller --onefile -w -i "Icon Name" "myapp.py" and I get the Dist folder with both a unix script and a macOS application. Running the Unix Script works perfectly fine, however when I try and run the app it will breifly blink in the taskbar and then dissapear without doing anything. running open myapp in the terminal opens it fine, its just when I double click on it.
I have tried looking it up and PyInstaller App not opening on Mac leads me to this github thread https://github.com/pyinstaller/pyinstaller/issues/3753. I tried following along however when I get to the hook-_tkinter.py file mine is only 30 lines of code and looks like this:
import sys
from PyInstaller import compat
from PyInstaller.utils.hooks import logger
from PyInstaller.utils.hooks.tcl_tk import collect_tcl_tk_files
def hook(hook_api):
# Use a hook-function to get the module's attr:`__file__` easily.
"""
Freeze all external Tcl/Tk data files if this is a supported platform *or* log a non-fatal error otherwise.
"""
if compat.is_win or compat.is_darwin or compat.is_unix:
# collect_tcl_tk_files() returns a Tree, so we need to store it into `hook_api.datas` in order to prevent
# `building.imphook.format_binaries_and_datas` from crashing with "too many values to unpack".
hook_api.add_datas(collect_tcl_tk_files(hook_api.__file__))
else:
logger.error("... skipping Tcl/Tk handling on unsupported platform %s",
It does not have the specific lines that the thread is showing I need to edit. I should also note that I found the file in /opt/homebrew/lib/python3.10/site-packages/PyInstaller/hooks/hook-_tkinter.py instead of where the thread is pointing to. I cannot find this file there.
I also read somewhere (I forget where exactly) that I need TCL and tkinter installed which I thought I did already cause it comes with python. trying to find somewhere to download tcl brought me to activetcl but I am unsure how to install that on my computer so I am not sure if that is the solution or not because I cannot get it working.
Sorry for the long question but would anyone be able to assist me in getting this working?
I have built a Cx Freeze exe from python code. Code worked fine. I recently modified one .py file and rebuilt the exe. Dragged the entire build directory over to another computer for use and it looked as though it was using an older version of the code. Rebuilt, retried. Same thing.
Ended up moving over the new updated python file to the other computer and the exe starts working correctly.
Looks like the exe is not truly independent of the uncompiled code?
Have any of you seen this? Is it a bug? Is there a fix?
thanks!!
I had this same issue and found some troubleshooting steps to fix the problem:
Change the version number in setup.py.
Change the name of the init.py (or whatever your first file is called.) Change the name in setup.py to match.
Copy your files into a separate folder along with the setup.py and rerun there.
I made a program using the pygame module on Python 3 and it works fine within python, but when I try to compile is using py2exe it won't run. (I just get the programName.exe has stopped working error upon trying to run it).
I managed to narrow down this problem to the pygame.font module as when I comment all the lines that use that module everything works fine. I tried to forcefully include the module using the -i flag in py2exe, but it doesn't appear to change anything...
What am I doing terribly wrong?
Edit: I managed to get the reason of the program not working - it crashes as it can not find build\executable.exe\pygame\freesansbold.ttf . What I don't understand is why the hell is the pygame folder supposed to be located in a folder with the name of my executable? (Of course, I can not create a folder with the same name as an existing file in the directory). If anyone has a clue to how to fix it, please help!!
I had the same problem using cx_Freeze, so hopefully this will work for you as well. Open up your pygame package folder. It should be C:\Python34\Lib\site-packages\pygame. There should be a True Type Font File titled freesansbold.ttf. Copy that file then open the folder containing your exe program. There should be a zipped file called library. Open it up and go to the pygame folder inside the zipped file. Should look something like this \build\exe.win32-3.4\library.zip\pygame. And just paste the freesansbold.ttf file in that folder and it should work perfectly.
I managed to find a way! By including -l library.zip argument in the build_exe command and then following the instructions given by DeliriousSyntax in the answer above I managed to get it to work!
http://pastebin.com/BJiXC022
At first my python is working just fine with tkinter. When I change the working directory, it somehow stops working then. It even manages to refer the tkinter.py file in that directory even when I never even typed the name of the file there. I just wanted to import tkinter. My tkinter.py file is also not working even though it is almost exactly the same as the first 10 lines. How do I fix this problem? I reinstalled os and python yesterday, I am running OS X 10.10.3 and the newest Python 3.4.3. Here's tkinter.py:
http://pastebin.com/VBHqFGLZ
You have a file named tkinter.py in /Users/nikolas/Documents/Python/tkinter.py. Changing to that directory and importing tkinter will import the local file, not the one from your Python installation. You see the error because your tkinter.py file does not provide Tk.
The solution is to rename your file to something other than tkinter.py.
EDIT: I found out that the error is that the resources couldn't be opened. Copying the directory into the folder where the .exe is didn't fix it. I tried removing the resources from the .spec file and the size of the .exe file is now 9 MB as opposed to 52 MB so I'm pretty sure the resources are included, but somehow they can't seem to be opened by the .exe. In case anything is wrong with it, This is my .spec file - I only modified the Tree thing to include the resources, the .exe filename and icon.
In other words, the question now is: Why can't the exe find my game resources, and what do I have to do to fix that? Also, I realised my resources folder has two subfolders - does that mean I have to go about writing the Tree differently?
I've made a game in Python (using Pygame, too) and want to make a single executable file so I can distribute it. PyInstaller seemed perfect for that, and eventually, after a while of searching, I found out how to get it working in this guide. After I tweaked my code to get step 2 working I created the .spec file, added the directory with the resources to it (as in step 5, and including the font file), copied it to the same folder the .spec file was in and finally I ran
build.py game.spec
and I found the .exe file exactly where it was supposed to be. However, when I open it, it just closes again after a few seconds, and I think it's just before the main menu shows up. I'm not really sure it's a font screw-up again though because I made sure to include it in the resources as well...
Unfortunately, searching for a solution on the web didn't help me at all, especially because half the links to the project are broken now.
If anyone knows what's gone wrong here (or needs more details) please let me know.
Details:
Python version: 2.7.7 32 bit
Pygame version: 1.9.3 32 bit
PyInstaller version: 1.5 32 bit
System: Windows 8.1 64 bit (the 32 bit programs have all worked fine so far though)
Try to open command prompt and drag exe into it and press enter, that way you will catch the error (if there is any) and then update your question, more info == more help.
I never used pyinstaller so I can't really help you on that.
Also I suggest you to try py2exe, it worked nicely with pygame (at least for me) and later you can make setup with NSIS or Inno.
Edit:
If the .exe can't permanently save the highscores (as you said in comment below) try running exe as admin, it might be just matter of write privileges , or maybe it is your antivirus who doesn't allow it to write (sandbox at Avast, unknown/rare file at Norton).
I didn't find out what the problem was but I did manage to get it working. I started by installing the newer version of PyInstaller (2.1) with pip and completing the same steps again, but this time in the Scripts directory and running pyi-makespec and pyi-build instead of makespec.py and build.py because that's how the new version works, I guess. At first it would still complain about the resources being missing unless I ran it from cmd, but I think that was actually because I forgot step 5 (Tree in the makespec file). For some reason now the .exe can't permanently save the highscores, but apart from that it's working perfectly.