pyinstaller "Failed to execute script" - python

(before start, i'm not good at eng.)
i'm making a python application.
everything was completed.
but, pyinstaller don't work well.
the file's name is "shojo.py".
i used this code.
pyinstaller -w -F shojo.py
and if execute the file,
this window appears.
error image
this time, i used this code.
pyinstaller -w -F -p D:\python\Lib\site-packages\PyQt5\Qt\bin shojo.py
but the result was same.
this is the log.
https://github.com/shojoinfo/shojoinfo/blob/master/shojo/source/log%2Ctxt
and i found the file "warn-shojo.txt"
this is the file's contents.
https://github.com/shojoinfo/shojoinfo/blob/master/shojo/source/warn-shojo.txt
what should i do?

Not sure if this is the cause, but from the logs I see you need to give path to install those missing modules.
See here:
https://pyinstaller.readthedocs.io/en/stable/operating-mode.html

Related

I tried to use this cmd `pyuic5` but it gave can't recognize

I have been trying to do PyQt5 designs, but when I want to transform it into .py file I can't. The pyuic5 error is always there in the cmd but when i try to use this command in the Pycharm terminal it works fine, I just need to change file directory in which I want the command to recognize it.
I want to use this function mainly:
pyuic5 -x test.ui -o test.py
This is what I'm facing, so if anybody has any solutions please share.

Why is the following .sh script saying .py command not found when the script is in PATH?

I am trying to run the Example Workflow in https://rki_bioinformatics.gitlab.io/ditasic/, in which example.sh is the major bash script that will take the example data and output some data matrices.
In the example.sh script which will run the example workflow, we have the following line 9:
ditasic_matrix.py -l 100 -o output/similarity_matrix35.npy data/reference_paths
However, when example.sh is run in the terminal of macOS, the following message arises:
DiTaSic /ditasic_example/example.sh: line 9: ditasic_matrix.py: command not found
But ditasic_matrix.py already exists in the path I have set for the terminal. I have put ditasic_matrix.py in a directory whose path I have added to the PATH of the terminal by
export PATH="$PATH":
So what has happened that leads to the command not found?
Change ditasic_matrix.py line in your script to be ./ditasic_matrix.py because of current path not being included in executable search.
If it still doesn't execute, maybe the file does not have executable bit set.
Open a terminal/console in that folder and issue
chmod +x ditasic_matrix.py
The ditasic_matrix.py file seems to have the following interpreter setting on it: #!/usr/bin/env python. Since you seem to not be able to run it, it seems that this is not your actual path to running Python. Please make sure that:
1) You have Python installed
2) You can execute Python programs by running python in the command line.

Pyinstaller "Failed to execute script pyiboot01_bootstrap"

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.

Permission denied for Python script using Bash?

I am new to Ubuntu... I am trying to run my first simple python program "Hello World" ...
After running following commands in terminal
1. chmod +x filename.py
2. ./filename.py
terminal is showing following error "bash: ./filename.py: Permission denied"
what can I do for solve about problem?
Do you have the appropriate incantation at the top of your python file? e.g.,
#!/usr/bin/python (or alternatively #!/usr/bin/env python)
Just to clarify, chmod +x only makes a file executable, it doesn't run it.
And I'm assuming your script looks like nothing more complex than this:
#!/usr/bin/env python
print 'hello world'
Some possibilities:
What does it say if you type umask? chmod +x will only make a file executable for you if your umask doesn't block the user executable bit. A typical umask such as 0022 will not block the user execute bit, but a umask like 0122 can. (See the Description section of chmod(1) for more info.)
To execute a script such as a Python script, you also need read permission. Try chmod u+rx filename.py and execute the script again.
It's also remotely possible that whatever interpreter you've specified in the file with the "hashbang" line at the beginning of your file (e.g. #!/usr/bin/env python) isn't executable, although that in my experience yields a different error message.
I deal with the same problem on my new system.
It is the third time I tried to solve this, and your post is the first one appearing on google results. My post is late, but think that it will help another users with the same problem.
In my case, it was about partition table setup.
Check in your /etc/mtab file how python script is being stored. Check if there is a clause: noexec
noexec is a flag that forbid executing under the partition. By default, it is set with exec. But, sometimes, this kind of things happen.
Now, it is working fine here.

starting Python IDLE from command line to edit scripts

I've tried many variations of this command: idle.py -e filepath, but it simply starts IDLE like normal, not opening any extra windows for editing, and not throwing any errors.
So how can I do the equivalent of opening IDLE, file>open>filepath via the command line (or perhaps even a Python module)?
You need to do as stated in the main.py file of the idelib folder (C:\Python33\Lib\idlelib), at least on the python 3.3 version explains that:
IDLE main entry point
Run IDLE as python -m idlelib
So with python -m idlelib <script_to_edit> you will be able to open and edit the script with idle. I haven't checked with previous versions but it could be the same comand
This is also documented on the changelog of the version 3.3.3
Make a new text file, and put something like this in it:
C:\Python26\Lib\idlelib\idle.pyw "C:\file1.py" "C:\file2.py"
In your actual script, you'll replace "C:\file1.py" and "C:\file2.py" with your files' paths, save as a .bat, and then launch it. That should do what you want.
Please forgive me for bumping such an old thread, but I've been teaching myself linux and python with the help of the community, and was trying to figure out how to invoke IDLE2 and IDLE3 from the command line. I came across this post some of the solutions seemed a bit complicated for my application. Then it occurred to me that I could just put syslinks in the /usr/bin/ path for each.
sudo ln -s idle-python3.1 idle3
sudo ln -s idle-python2.6 idle2
to address the OP. From the directory the script is located, type:
idle3 abc123.py
or
idle2 abc123.py
I'm just so damned happy that I finally had a "light bulb" go off that I wasn't going to let a 2 year old post stop me from posting my solution.
Rarely the native os is useful. I created a 'win batch file, in the folder with my .py files:
start /MIN cmd /C c:\Python27\lib\idlelib\idle.py -e %1 %2 %3 %4 %5 %6
This can open up to six files from cmd line in one shot. Just type the name of the batch file, followed by from zero to six filenames. Also if one or more files you specify are not found, idle opens these as new document(s).
first make sure you have location of idle in path
I am using "python3.5".So mine looks like this:
C:\Program Files\Python35\Lib\idlelib.Yours may differ.
use this following command:idle -r file_name.py to run the file
or just idle file_name.py to edit
or start idle -r file_name.py ^&exit
you can just program in Python to edit your Python files. A simple example. say you want to search for a word and then replace it with something else.
import fileinput
import os
os.chdir( os.path.join("c:\\","path") )
for file in os.listdir("."):
for line in fileinput.input(file,inplace=0):
if "search word" in line :
line=line.replace("search word","new word")
print line
(use inplace=1 to do in place editing.). Then save and run the script as normal Python script using the interpreter.
Just add IDLE's path to your PATH environment variable.
For example I created an environment variable called IDLE_PATH and set the value to C:\Python27\Lib\idlelib
Then in my PATH variable I added ;%IDLE_PATH%; and open a new cmd prompt or in console2 just open a new tab and run idle <file_name> to open the file, you will be able to do this from any directory. In IPython console add an ! before the command, for example !idle test.py.
Congrates, Now you're a python pimp!
paste the idlelib to your system path or user path, environment variable.for example, like this
C:\Program Files\Python310\Lib\idlelib
then type idle in your command prompt. done.

Categories