Python ImportError when building exe - python

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.

Related

Pyinstaller include given imports

I got some imports
from time import sleep as wait
from playsound import playsound
import random
import os
from threading import Thread
import sys
I want all imports to be installed into my exe file when building .exe, bcs playsound (pip package) doesnt be imported
Done = Building my exe file and ran it
Happen = ModuleNotFoundError: No module named 'playsound'

Pyinstaller Error when running the exe file

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

Can't import class and module on Python progrram

I do not program on Python, so I don't know what the problem is.
I just can't start the program from the command line, this is displayed:
Here is code __init__.py
import os
import sys
from PyQt4 import QtGui, QtCore
from pynfb.experiment import Experiment
from pynfb.io.xml_ import xml_file_to_params
from pynfb.settings_widget.general import GeneralSettingsWidget
from pynfb.settings_widget.inlet import InletSettingsWidget
from pynfb.settings_widget.protocol_sequence import ProtocolSequenceSettingsWidget
from pynfb.settings_widget.protocols import ProtocolsSettingsWidget, FileSelectorLine
from pynfb.settings_widget.signals import SignalsSettingsWidget
from pynfb.settings_widget.composite_signals import CompositeSignalsSettingsWidget
from pynfb.settings_widget.protocols_group import ProtocolGroupsSettingsWidget
static_path = os.path.realpath(os.path.dirname(os.path.realpath(__file__)) + '/static')
class SettingsWidget(QtGui.QWidget):
You need to install PyQt4 first: https://www.lfd.uci.edu/~gohlke/pythonlibs/#pyqt4.
Download the correct file corresponding to the version of your python, e.g. PyQt4‑4.11.4‑cp37‑cp37m‑win_amd64.whl then install by using pip (https://pip.pypa.io/en/stable/installing/)
pip install PyQt4-4.11.4-cp37-none-win_amd64.whl

transform python tkinter GUI to EXE file

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

How do i convert a python3.4 script(that has installed modules) into a windows executable using py2exe?

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.

Categories

Resources