I tried to create a small .exe file using pyinstaller but it is showing an error - pyinstaller

I tried to create a small .exe file using pyinstaller but it is showing an error "The Application has failed to start because it's side-by-side is incorrect. Please see the application event log or use the command-line sxstrace.exe tool"
Error image

Related

I am trying to convert a python .PY file to .EXE. But the EXE file won't run because of "Fatal Error Detected Failed To Execute Script Error" Help Pls

I am a absolute beginner with Python. What I have done so far is I have installed Python with IDLE, Pycharm, Pygame-zero and Pyinstaller too. I have a (.py) file game I would like to turn into a (.exe) file. So I can release my game for my friends to play.
I have entered this command into CMD window "pyinstaller --onefile -w gamename.py"* (*My game is not really called "gamename". I have called it that in this code above. For this example only.)
When in the file folder of my game and then Pyinstaller converts my file into the (.exe) file. But everytime I try to run this file. It fails with this error message - "Fatal Error Detected, Failed To Execute Script Error".
I have watched all kinds of YouTube videos trying to solve this problem and have tried these following fixes:
Updated Pyinstaller (4.3).
Updated Python (3.9.5).
Changed the path in Enviroment Variables to point to Python39\Scripts and resetting my computer.
Coverted the (.py) file to (.exe) by including the console window. Then after running the program after when the console window disappears. Opening the CMD window again and typing the file directly "gamename.exe" to run.
Installing auto-py-to-exe program.
Each time deleting the Main, Dis and Spec files and moving the (.exe) file into the main file folder. With the resources for the games. Music, Images and Sounds.
Testing out my Python script to check. If it doesn't have any errors while loading through IDLE and it doesn't. It works straight away, I can play my game through IDLE. There is no errors in the code of my game script.
And after trying all of these solutions it still hasn't solved this issue.I still have the same error message appearing when trying to run my game. Now I have found out what the meaning is to this error message that appears. Which is:
"Fatal Error: failed to execute
This means something has gone wrong as it's giving you a visual warning about it; this is not an error, it's a warning; the real error has been printed to stdout/stderr. If you open the executable using the terminal or something else that will preserve the console output, you will most likely see a Python error telling you what went wrong. Fixing this and repackaging is the solution to this issue".
I have remade the (.exe) file including the console window and it does explan what the error is. When I try to run my game, the error comes up as:
"FileNotFoundError: {Errno 2} No such file or directory: C:*****\Local\Temp_MEI58602\pgzero\data\icon.png {4268} Failed to execute script.
Any suggestions? On how to fix this error please. So I can run and play my game outside of Python on any PC.
A Possible Answer:
I have found a webpage that has the possible answer to my problem. But I don't know what they mean, because I am a beginner with Python. Can anybody read this and break it down for me? Here is what it say's:
"Pyinstaller packaging exe, missing icons and other issues
Reason
When the exe runs, it will decompress a resource folder named "_MEI*" to a temporary directory on the computer, and delete it when the program ends.
uses a path like ‘\icon.png’ in the program. When the exe is running, it will only search for its own directory, of course it cannot be found.
Two, the solution
Make sure the picture is in this temporary resource folder
This can be done by editing the'.spec' configuration file to add pictures.
(Note: .spec is the file generated by Pyinstaller last time, in your python project directory.)
These are the three pictures I used, which is actually adding three tuples to the "binaries" list
Before the comma is the address of the picture in the python project, after the comma is the address of the package into the ‘_MEI*’ temporary folder.
I have built an ‘img’ folder to store pictures in it. Just put a dot in the root directory, such as (’./img/info.png’,’.’)
Finally, run when packagingpyinstaller program entry.spec, You can add the picture resource.
(Note: Other external resources can also be added in this way, such as .ini, .txt, .exe, etc.)
Make sure the program can find this path
Because the name of the temporary directory is different each time, a method is needed to dynamically obtain this path.
The code is presented, and the core statement is ‘os.path.realpath(sys.path[0])’.
Python running effect is as follows:
Package it as an exe, drag it to the cmd window and run it."
Here is the link to the webpage to the article. Because it makes use of screenshots that I can't include on this webpage;
(https://www.programmersought.com/article/94965073850/)
Please read this acticle and break it down for me. It does seem to be explaining the solution to my problem. But what does it all mean? What pictures is he talking about? Please explain.
I am not sure why but PyInstaller doesn't seem to bundle everything needed for Pygame Zero, including that icon.png file. The solution is simple, though. You just need to use pyinstaller --collect-all pgzero --onefile -w <scipt_name>. If your game has sounds, images or anything like that, remember to include those specific folders as well using --add-data <file_or_folder>. Also, make sure your script includes the following lines.
import pgzrun
# GAME CODE HERE
pgzrun.go()
I hope it helps, even though it is a little late.

How to fix Error in setwd("D:/") when opening R

I'm currently trying to Knit a file with RStudio and keep running into the below error:
Error in setwd("D:/") : cannot change working directory
Execution halted
However, when I check getwd() I get "/Users/my-name" as the working directory. I have also tried setwd("~/") and receive the same error in Markdown. Further, when I initially open RStudio I get
Error in setwd("D:/") : cannot change working directory
which suggests that there is an issue when I start R. Is there a way to get this error to stop from occurring when starting RStudio in the first place? I've tried deleting and redownloading RStudio but that doesn't seem to work. I'm currently using Mac OS Catalina.
Below is a screenshot of the error I receive when I open RStudio.
Thanks in advance.
I got similar issue with "setwd". When I did "save as" my existing code file from other folder to a new folder then I got an error: "cannot change working directory". When I did copy a code file from other folder and paste it into a new folder then I was able to run "setwd" and there was no error.

pyinstaller unable to fetch required module

I am trying to make a file uploader using pcloud. While doing so when I run my python code from Pycharm, it works perfectly fine. But when I convert it into exe using pyinstaller, it gives me "fatal error - failed to execute script"
here's my code
from pcloud import PyCloud
pc = PyCloud('myemail', 'mypassword')
print('connected !')
exact command used in pyinstaller was "pyinstaller --onefile myfile.py"
read about hidden imports, but dont know how to exactly add the module pcloud in my exe.
Any help would be appreciated !

.jar file quickly opens, then closes

I am trying to make a FTB server that me and my friends can play on. So, I downloaded the .jar and it said "Choose what to open with. SO, I assigned java binary to what it is opened with. It then now opens, but then not less then a second later, closes. I tested with other .jar files. Each one of them either didn't open at all, or opened quickly, then closes. WHat could be wrong?
More than likely the jar (which is just a zip of the programs main classes) is running into an error and exiting.
In order to find and resolve that error you need to see the error message!
first locate the jar file in either your terminal or command prompt and run the following command
java -jar <YOUR_JAR_FILE_NAME>.jar
You will see any output sent from the java program to the console so you can diagnose and resolve it!
In your terminal, where your .jar file is located, type and run the following command :
java --enable-preview -jar <JAR FILE NAME>.jar
Most probably the .jar fill will open, or it will show you the error, which you can then resolve.

Flex Debugger wont launch - Only on particular project

When trying to launch Flex debaugger on my project, it does not launch and I get an error instead. Every other project in different workspaces launches just fine. This is the only one giving me an issue.
Here is the error:
Process terminated without
establishing connection to debugger.
Command:
"C:\Program Files\Adobe\Flex Builder
3\sdks\3.2.0\bin\adl.exe"
D:\fromLapTop\lapDocs\Flex\Workspaces\MothersRings\MothersRingsAir\bin-debug\MothersRingsAir-app.xml
D:\fromLapTop\lapDocs\Flex\Workspaces\MothersRings\MothersRingsAir\bin-debug
Output from command:
PreloadSwf paths must be local
trusted:
D:/fromLapTop/lapDocs/Flex/Workspaces/WebRequestNotifier/.metadata/.plugins/com.adobe.flash.profiler/ProfilerAgent.swf?host=localhost&port=9999error
while loading initial content
Anyone have any ideas on how I can fix this?
Thanks!
Can you try copying the pre-loadSwf path to C:\ drive too? Just a guess..

Resources