i am created executable file from 'Cx_freeze' ,when iam executing the executable file from command prompt, i am getting the below error
Modulenotfounderror:no namee module 'reportlab.graphic.barcode.code128',
i have multiple python file is my folder(.py).
i am also created executable file from 'pyinstaller' , but when i am executing executable file from command prompt, i am not getting desired output. any suggestions?
which one is better to proceed
[error screen shot added here][1]
[1]: https://i.stack.imgur.com/E5sO9.png
Related
I wanted to use pyradiomics to extract radiomic features from medical images in MATLAB, so I tried to transfer my FeatureExtraction file to an exe file, then call it in MATLAB. I used pyinstaller -F -w FeatureExtraction.py in command line, then I got an exe file FeatureExtraction.exe. But when I called the exe file in MATLAB, there was an error : pykwalify.errors.CoreError: <CoreError: error code 3: Provided source_file do not exists on disk :C:\Users\ADMINI~1\AppData\Local\Temp\_MEI318322\radiomics\schemas\paramSchema.yaml: Path: '/'>
I tried to run the FeatureExtraction.py in Pycharm, there was no error. I could get the result I wanted. Then I uninstalled and reinstalled some packages use in the file, there was still no error. But when I called the exe file compiled from the python file in MATLAB, there was still that error:
pykwalify.errors.CoreError: <CoreError: error code 3: Provided source_file do not exists on disk :C:\Users\ADMINI~1\AppData\Local\Temp\_MEI318322\radiomics\schemas\paramSchema.yaml: Path: '/'>
Code for the background image of the GUI :
bg = PhotoImage(file='images/all_button.png')
lbl_bg = Label(root, image=bg)
lbl_bg.place(x=0, y=0, relwidth=1, relheight=1)
Error
Traceback (most recent call last):
File "finalbilling.py", line 14, in <module>
File "tkinter\__init__.py", line 4061, in __init__
File "tkinter\__init__.py", line 4006, in __init__
_tkinter.TclError: couldn't open "images/all_button.png": no such file or directory
[7912] Failed to execute script finalbilling
There are many ways in which you can convert it into an executable program.
But one such easy way is to use pyinstaller.
Firstly, download a module named pyinstaller by entering the below code into your console:
pip install pyinstaller
Then, open the folder in which you have kept your program with console.
In windows, you can go to the folder and press shift key and right click to get the option to open with powershell.
In Mac, you can head to the folder > Right click on the folder > Click New Terminal at folder.
Then in the terminal you can either:
pyinstaller (name of your file).py
In this one you will get many other files associated with your executable program.
Don't try to delete those files else your executable file may get affected.
Instead, try the below one to get only one executable file.
pyinstaller --onefile (name of file).py
You can get the executable program into dist folder of the folder you opened into console.
And then you can convert it to zip and send others.
If you are getting any type of errors like:
No such file or directory [7912] Failed to execute script finalbilling
Then there might be an issue with your script or while opening or importing any file an error occurred.
As the same happened with me and after resolving the issue in script it worked.
So, try to resolve the issue in script and then try the above steps it will definitely work.
You can convert the python script to a standalone executable with all its dependencies included using different python packages. One such package is pyinstaller which can be used to create executable for Windows, Mac OS X, or GNU/Linux. pyinstaller
pip install pyinstaller
pyinstaller --onefile main.py
OR
pyinstaller --onefile -w main.py # (will not work for console app)
-w means not to open CMD
I'm trying to convert my py file to an executable but after the pyinstaller process , i'm getting the Failed to Execute Script error.
I tried to do it with the auto-py-to-exe app for this and get same error , also tried with the pyinstaller via cmd code and same error again .
So basically the file is on the desktop/pythonBot folder, but the cmd cant open it up? The code I type in is python bot.py. I followed this dude's guide here:
https://www.smartspate.com/how-to-create-a-telegram-bot-with-ai-in-30-lines-of-code-in-python/
(Sorry I am just a senior high student with no coding background)
From screenshot i guessed you have .py in another directory.
cmd is searching for "bot.py" file in C:\Users\s9800 directory.From error i can guess your bot.py file is in another direcotry.Provide full of .py file
How to run .py file
1st way :open cmd,drag and drop .py file to cmd and press enter
2nd way:Go to directory where your .py file is.Wrtie "cmd" in address bar ,it will open cmd ,type file name and press enter.
It looks like you are not in the correct directory, us cd to navigate to desktop/pythonBot or alternatively, use the full path when running the file.
I have created GUI python2.7 program with Tkinter successfully without error. Now I want to make an executable file of it using pyinstaller in anaconda environment (I'm using windows 10).
Using this command
pyinstaller --onefile main.py I am able to create exe file successfully in dist folder. But when I tried to run the exe file, it showed error :
Traceback (most recent call last):
File "main.py", line 333, in <module>
File "main.py", line 90, in __init__
File "lib-tk\ttk.py", line 715, in current
_tkinter.TclError: Index 0 out of range
[22668] Failed to execute script main
Is the problem related to tkinter? I've tried the solution here : Problems with Pyinstaller with tkinter app on python 3.5 and here : How to make pyinstaller import the ttk theme? . But still same error
Try and do:
pyinstaller --onefile -w main.py
The -w flag stops python from bringing up the console, and so this could be why tkinter is failing.
Source:
This cool video
I highly recommend you watch this video as it also goes a little in depth on how to clean up after building the exe.
I used pyinstaller to create single exe file for a tkinter project, which contained several py files:
Main.py is my main python file which calls tkinter UI and I had several other python files imported to this Main.py.
Some libraries which I used include pandas,pyodbc
Open cmd in the same directory of the project; Use following command:
pyinstaller --noconfirm --onedir --windowed --icon=XYZ.ico "C:/Users/.../Tkinter_Project/Main.py"
Application was created with no dependencies. If there is any config or image files used, simply copy paste it to the 'dist' folder which gets created.