Can't open Pyinstaller's output file - linux

SOLUTION:
The main issue was occurring due to ImageTk , this can be skipped by loading image using tkinter instead of PIL.ImageTk by using this command and using this object as normal you would do with PIL.ImageTk.
my_image = PhotoImage(file ="Image location here")
MAIN ISSUE:
I'm trying to pack these files into a single executable file using pyinstaller, but after compilation, the executable file doesn't run, don't know where the error is, files in the given link, and installation log in pictures
Command Used:
pyinstaller --onefile ui.py
Where ui.py is my driver script
Files:
https://github.com/RoyalEagle73/NIT-JSR-Result-Leecher/tree/master/GUI%20%2B%20Source%20v2.0/Source
Build Log( Images ):
What I've already tried
tried Cx_Freeze as an alternative but no application seems to open the output file.
here is what I'm importing overall in the whole program
from tkinter import *
from PIL import ImageTk, Image
import fb
from tkinter.ttk import Progressbar
import webbrowser
from tkinter import messagebox
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import re
from bs4 import BeautifulSoup
import time

I was not able to access the github link in your question, I think it did not get pasted properly. So I am unable to access your source files.
Try one of these:
pyinstaller --onefile --noupx ui.py
or
pyinstaller --debug --onefile --noupx ui.py
The pyinstaller uses UPX. The documentation for pyinstaller states the following:
PyInstaller looks for UPX on the execution path or the path specified
with the --upx-dir option. If UPX exists, PyInstaller applies it to
the final executable, unless the --noupx option was given. UPX has
been used with PyInstaller output often, usually with no problems.
Hope this helps.

Related

PYINSTALLER exe not executing - blank terminal closes in 10 seconds

I am trying to make a small Python app to share with non-developers to help automate a small task.
The problem is that the .exe gets generated, and throws a mkl_intel_thread.1.dll issue. I then found the .dll and pasted it in the same folder as the .exe. Now the .exe runs without error, but closes without doing anything.
The python script runs fine and prints these when run separately (as a python file).
I read a lot on similar issues and did try many things, but nothing seems to work. Could anyone help me out, please?
Python code (prints pandas version, and then reads a file to print the number of records) :
I have some additional imports as I want to test their dependency for the actual program where they are used.
import requests
from glob import glob
from bs4 import BeautifulSoup
import pandas as pd
from datetime import datetime
from time import sleep
def View_model():
print(pd.__version__)
sleep(10)
data = pd.read_csv('test_data.csv', sep=';')
data_cnt = len(data)
print("Total records : ", data_cnt)
sleep(10)
if __name__ == "__main__" :
print("started")
View_model()
print("completed")
sleep(10)
Pyinstaller .exe generation command(s) :
pyinstaller -F --hidden-import 'numpy' --hidden-import 'requests' --hidden-import 'glob' --hidden-import 'bs4' --hidden-import 'pandas' --hidden-import 'datetime' --hidden-import 'time' --add-data "test_data.csv;." check1.py
Am I doing something wrong in the process, or is it something non-obvious that is going wrong?
Appreciate any help/leads. Note that I have the .dll file in the same folder as the .exe (see below)
I am using Miniconda (conda 4.10.3) & have Python 3.9.7

Error with python executable : cannot import name ttk from tkinter

I have a python (3.8.3) script which works perfectly. However, when I create an executable with the following command :
pyinstaller --onefile gui.py
I get the following error : **
cannot import name ttk from tkinter
The error appears at this line :
from tkinter import ttk
I can not remove the import as "ttk" is really needed in my program.
I tried to create it with cx_freeze but I get the same error.
Do you have any solution for this problem ? Thanks.
Try one of these ways to compile your script:
pyinstaller --onefile gui.py --hidden-import=tkinter.ttk
pyinstaller --onefile gui.py --hidden-import=tkinter
If you tackle another import problem it would be better to compile using .spec file where you can specify hidden imports

Pyinstaller with anaconda in spyder

So i wrote a little programm in python with use of tkinter. The repo is found here: https://github.com/Odatas/MeisterTools
I now want to create an exe so people only need to use the exe when they want to use the program. But the exe i create with pyinstaller doesnt work and throws the error:
Import Error: cannot import name 'travel' from 'main'
The cmd i opend to creat the exe is directly out of anaconda envoirment.
I cd into the folder where all the scripts are and then run it like this:
pyinstaller --onefile patrickstools2.py
I even tried to make every import an hidden import:
pyinstaller --onefile --hidden-import=init --hidden-import=main --hidden-import=checker --hidden-import=contact --hidden-import=dangers --hidden-import=droptable --hidden-import=importexcel --hidden-import=odatasfunctions --hidden-import=randomenpc --hidden-import=scrolltest --hidden-import=sonstiges --hidden-import=travel patrickstools2.py
that doesnt help either. I added the path through Anaconda to the PYTHONPATH variable...so it should be know in any way shape or form.
The complet code is in Anaconda. The Error gets thrown in the import section of the main file:
# page classes import
import os
try:
import Tkinter as tk
except ImportError:
import tkinter as tk
try:
import ttk
py3 = False
except ImportError:
import tkinter.ttk as ttk
py3 = True
# page classes import
from . import travel
from . import contact
from . import dangers
from . import sonstiges
from . import randomenpc
I allready created an exe with pyinstaller from a previous version. But i made some changes to the structure of the programm. The run.py is only there because i work with spyder and as far as i know spyder needs it because else the import doesnt work correctly.

Pyinstaller: fatal error, failed to execute script

This is a recurring theme, distributing python code seams to be a non-ending issue (I have checked all related answers I could find on SO regarding this).
I have a script containing the following imports:
import tkinter as tk
from tkinter import *
from tkinter import messagebox as mbox
import pandas as pd
import time
import os
import glob
import base64
import matplotlib.pyplot as plt
from PIL import ImageTk, Image
plt.style.use('bmh')
It's basically a GUI containing several buttons (each launching a function that reads from a pandas data frame and shows a graph via a Matplotlib plot) and also a label with a logo.
I've tried my usual tweaking with pyinstaller (and also with and without the label image:
Simple (one file and without):
pyinstaller -F -w --noconsole -i icon.ico Script.py
Complex:
pyinstaller -F -w --noconsole --noupx -p C:\Users\USER\AppData\Local\Continuum\Anaconda3\Lib\site-packages --hiddenimport pandas --hiddenimport matplotlib --hiddenimport PIL --add-data "image.png;image.png" -i Fuji.ico --log-level=DEBUG Script.py
And every variation in between.
I have removed from Pyinstaller/loader/rthooks.dat the line 'PyQt4': ['pyi_rth_qt4plugins.py'] which is know to cause some issues.
I get the same error again and again:
Versions:
Pyinstaller 3.3.1 (/!\ Edit: I tried also with the dev version, same result)
Python 3.5.3
The results from the warn file in debug mode: https://pastebin.com/na0W4TGS
Does anyone have an idea on how to solve this?
I solved the issue by pasting the label image to the .exe folder and also the platforms folder from:
C:\'Users\USER\AppData\Local\Continuum\Anaconda3\Library\plugins

Using py2exe by just running the script, no command-line

I know there's already a question like this but the answer didn't work for me.
When I append the py2exe argument in the program, and run it, I noticed it's missing a bunch of files. Also when I run the exe, it says
File "boot_common.py", line 46 in <module>
ImportError: No module named 'ctypes'
Can anyone help me on how to fix this? Here's my code:
from distutils.core import setup
import py2exe, sys
import tkinter as tk
from tkinter import filedialog
input('Press Enter to continue and select your Python file you want to convert when the dialog shows up...')
tk.Tk().withdraw()
file_path = tk.filedialog.askopenfilename()
sys.argv.append("py2exe")
setup(console=[file_path])
Also if it helps, I'm using a 32-bit Python interpreter.

Resources