I'm trying to make my python program run on other systems without python installation. I made use of tkinter to create a gui, after creating an exe file with pyinstaller it throws a fatal error "Failed to run script". I've checked my code several times and it works well. I don't know what's wrong.
Create the file using the -F switch only and run from your command line. You should see the actual error.
build: pyinstaller -F your_script.py
run: C:\some_dir\dist\your_script.exe
I have run into issues like this when a module is in a directory that is lowercase and pyinstaller is looking for an uppercase first character. e.g. C:\Python27\Lib\site-packages\queue vs C:\Python27\Lib\site-packages\Queue
The error is very generic and at this point, it may not be possible to find the actual error what preventing the execution.
In order to get actual error please exclude '--windowed' or '--noconsole' parameters during installation and then execute with 'pyinstaller -filename.py --onefile'. Then on execution it will show exact error instead of 'Fatal error! Failed to execute script'. Then you can proceed accordingly.
Related
I'm working on a VirtualBox Machine running Ubuntu 20.04 as the software. I'm using the virtual machine to create executable scripts using pyinstaller that will work across several platform types.
What Happens
Using the terminal, I run python3 -m PyInstaller --onefile "filename.py", which works as it should and creates a single file of the program. However, the name of the program is just that, the name. There is no file type associated with it and the end is just blank. For example, if the program name is program v.1.0.py, the executable's name is program v.1.0. Once I click on it, it will not run and nothing will show up. The log file I have set up shows the error CRITICAL: Program experienced unexpected error. Program terminated with EOF when reading a line. From my research, I understand this can happen when there is an input clause that is not fulfilled, which makes sense as the first line of the code begins with an input line.
What Should Happen
The executable should pop up a terminal dialogue as it does on my Debian and Windows devices, but instead, I get nothing, not even an indication of something going wrong. If anyone has experience with something similar and an idea of how to fix it, I would appreciate the help.
I am a beginner coder who is moving from pycharm over to sublime text. From what I understand you can run programs in the command line or in terminal and I want to make sure I can do both. When I try to run my file by inputting "python 3&5Multiples.py" it runs the program and outputs this response. Ignore the first line as that is my input, I included it because it may be helpful to understand what is going on.
MyiMac-iMac:py ianbridges$ python 3&5Multiples.py
[1] 71175
-bash: 5Multiples.py: command not found
MyiMac-iMac:py ianbridges$ /Library/Frameworks/Python.framework/Versions/3.8/bin/python3: can't open file '3': [Errno 2] No such file or directory
How do I make it so this text never appears and I just get the output of the program? Thanks!
As per your shell command, anything after the & is considered as a separate command. So, in order to tell the shell that you want it to be considered entirely as one term, you must use double-quotation marks. So, you can edit your command like so:
$ python "3&5Multiples.py"
PS: Don't include $ in the command
I'm using pyinstaller to produce an exectuable for a python program. But, whenever I try to use a generated executable, I get a message window that reads "Failed to execute script ...".
The command I'm running is pyinstaller -w run.py. But, when run with the --debug option a different error is made apparent. "Failed to execute script pyiboot-1_bootstrap". After this error it kills the program.
I tried with the -F option and that did not change the outcome. All the files I created for the project are in the same directory. I did get warnings that dll's weren't being included but I resolved that.
Pyinstaller doesn't like the built in quit() function I was using.
Instead use sys.exit() to close the program.
See this question to see why sys.exit() is better practice for production code.
What I found useful was to make an exe of my .py script in console mode and then run it. For a very short period of time, I saw an error message in the console window. I had to screenshot it to read completely. So one of the imports was missing from the folder in which I had my script. I opened cmd from the location bar of that folder (by typing cmd there) and imported modules using pip install <module_name>.
Sorry for the long answer, I am a newbie.
I am using python to write an automation script where I would like to start appium programmatically each time it is run. I am running my scripts using a MAC. I have tried many things to get appium to run and all I get are errors about file or directory not found and nothing happens. Here are some details:
Running 'which appium' using terminal gives me /usr/local/bin/appium
Looking at /usr/local/bin/appium shows it's an alias (not sure if that's helpful)
I have tried to run subprocess in various ways in my code with no luck.
I tried all the suggestions in Python subprocess.call a bash alias and nothing worked.
I tried using os.('path/to/appium') and no good.
I created a bash file starting appium located on my desktop which runs great when I manually run it, but comes back with 'line 1: appium: command not found' when I run it.
Apparently when I run python, it can't find appium, but I'm stumped at this point. I have /usr/local/bin in my .bash_profile in PATH. Is this not enough?
or should I be trying to start appium a different way?
Thanks for any help!
Error messages I'm getting are:
FileNotFoundError: [Errno 2] No such file or directory: 'appium --port 4725'
I am working with my Raspberry Pi 2 B+ and I am using Raspbian. I have a python script located at /home/pi/Desktop/control/gpio.py
When I type /home/pi/Desktop/control/gpio.py into the command line, I get the message
bash: /home/pi/Desktop/control/gpio.py Permission denied
I have tried running sudo -s before running that command also but that doesnt work. My python script is using the Rpi.GPIO library.
If someone could please explain why I am getting this error it would be appreciated!
You will get this error because you do not have the execute permission on your file. There are two ways to solve it:
Not executing the file in the first place. By running python gpio.py python will load the file by reading it, so you don't need to have execute permission.
Granting yourself execute permission. You do this by running chmod u+x yourfile.py.
However, doing so will not work unless you add a shebang at the top of your python program. It will let your linux know which interpreter it should start. For instance:
#!/usr/bin/env python
This would try to run python using your current $PATH settings. If you know which python you want, put it here instead.
#!/usr/bin/python3
Remember the shebang must be the very first line of your program.
do like this maybe work:
cd /home/pi/Desktop/control/
python gpio.py
Because gpio.py is not a executable file, you should run it by python instead