I wrote python script which include tkinter, sqllite3, matplotlib and other libraries. When I bundle the script to exe file by using pyinstaller, it's finished successfully but when I run the exe file it's giving me this error:
Need to mention that I don't use any library name babel.
I also add my code to the application below:
# Core PackAages
import tkinter as tk
from tkinter import *
from tkinter import ttk
from tkinter.scrolledtext import *
import tkinter.filedialog
from tkcalendar import Calendar, DateEntry
from tkinter import messagebox
from tkintertable import TableCanvas, TableModel
from tkinter import ttk
import matplotlib.pyplot as plt
from fpdf import FPDF
#background
# Database
import sqlite3
import csv
You seem to have similar problem as here. The solution is simple, add hidden import:
pyinstaller.exe --hidden-import babel.numbers script.py
Related
I'm trying to run a python script that has the following import statement:
from ast import keyword
from email.policy import default
from msilib.schema import ComboBox
from statistics import variance
import tkinter as tk
from tkinter import Variable, ttk
from turtle import onclick, width
I get an error on From msilib.schema import Combobox. I'm using a Mac and I see the lib is Microsofts, is there a way I can import a package so that I can use msilib on my Machine.
EDIT: The work around for anyone having the same issue is to run a virtual box with windows. It would still be nice to know how to run it on MAC but oh well...
I have a python code which i'm converting into exe
The code is working fine in development when i'm running code in terminal
This error is coming when i'm opening the exe
My script modules
from tkinter import *
import tkinter as tk
from PIL import ImageTk, Image
from tkinter import messagebox
import pymysql
import time
import pyautogui
import datetime
from datetime import datetime as dt
from datetime import datetime as dt1
import win32gui
import psutil
import os
import requests
import win32process
import operator
import random, string
import threading
import sys
import os.path
from ctypes import Structure, windll, c_uint, sizeof, byref
from tkinter import messagebox
from pynput.keyboard import Key, Listener
import logging
Possible error is comng from here i think - from pynput.keyboard import Key, Listener
Try build exe this way:
install pyinstaller: pip install pyinstaller
Open cdm -> navigate to folder -> enter following command:
pyinstaller.exe --onefile --icon=myicon.ico --windowed app.py
--onefile : create only .exe in one file not in folder with many files
--icon: if you have icon you want to use for .exe file
--windowed: to open windowed mode.
I have been working on developing a GUI application using tkinter which is 100% working properly when running it from pycharm... and now I can't convert my script into an EXE file.
I have tried pyinstaller, cxfreeze and py2exe but everyone of them has a problem. pyinstaller show me 'Fatal error'... and cxfreeze seems to have a problem with MATPLOTLIB
Here are the libraries I am using:
import numpy as np
import tkinter
from random import randint
from tkinter import *
import tkinter as tk
from math import sqrt
from matplotlib.backends.backend_tkagg import (
FigureCanvasTkAgg, NavigationToolbar2Tk)
from matplotlib.backend_bases import key_press_handler
from matplotlib.figure import Figure
import matplotlib.pyplot as plt
from math import sqrt
from scipy import stats
from scipy.stats import beta
I don't want to post my code due to confidientality issues...
Does anybody has another idea ot do this ?
EDIT:
I reinstalled python as admin and reinstalled pyintaller
enter image description here
and when I tried to convert the script here is the command error it shows:
'pyinstaller' is not recongnized as an internal command or external ...
also I need to mention that the exe file of pyintaller in not founded in the directory of installation of python in C:programfiles/python37
I am doing a small game in which I use "from tl.testing.thread import ThreadJoiner" to execute threads when executing from console the program as such works but when creating the executable with the help of cx_freeze I have the problem that when executing the program I get an error respect tl tells me that the module tl is not found and the program is not executed.
the error is this:
C:\Users\The.hacker\AppData\Local\Programs\Python\Python36-32\lib\site-packgages\cx_freeze\initscripts\_startup_.py",line 14,in run
module.run()
file:
C:\Users\The.hacker\AppData\Local\Programs\Python\Python36-32\lib\site-packgages\cx_freeze\initscripts\Console.py",line 26,in run
exec(code,m._dict_))
file "the_last_warrior",line 11,in <module>
Modulenotfounderror:no module named tl
on line 11 is the from tl.testing.thread import ThreadJoiner
now the image:
my file main is "the_last_warrior.py"
from tkinter import *
from tkinter import ttk
import tkinter as tk
import tkinter
from tl.testing.thread import ThreadJoiner
import threading
import datetime
from threading import Thread
has more than 1600 lines,In itself, how would the correct import of this module be? (from tl.testing.thread import ThreadJoiner)
picture of error:
console_vs_exe.jpg
After trying many things, I solved by copying the package directly from the folder "Lib \ site-packages" my package "tl" and paste it into the Lib folder of my program already ready after using the setup.py the program executes runs as I expected.
I have a python script that i have to import all these modules, which some of them require downloading:
import datetime
from dateutil import parser
from tkinter import filedialog
import tkinter
import mailbox
import pprint
import json
import urllib.request
from tkinter import *
Is there a way, using py2exe, i can convert the script into a windows executable. If so, how?
To simplify the procedure, you will want to have all your modules already downloaded. This can be accomplished with a simple "pip install " from command prompt. Then it is as simple as writing and running a setup.py file - detailed directions for how to do this can be found here.