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'
Related
I am converting a python file to .exe using pyinstaller v5.0.1, but I got this error when I run the exe file:
ModuleNotFoundError: No module named 'reportlab.graphics.barcode.code93'
Note that the python file is working perfectly and I'm not even using code93 in my code.
I have fixed this issue by adding an import for all this libs even if I don't use them:
from reportlab.graphics.barcode import code93
from reportlab.graphics.barcode import code39
from reportlab.graphics.barcode import usps
from reportlab.graphics.barcode import usps4s
from reportlab.graphics.barcode import ecc200datamatrix
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 created a script where we are using multiple imports as:
import re
import time
import easygui
import can
import threading
On Converting the script to exe using pyinstaller, it fails to include the can module and hence we get error as 'CAN module not found.
Need your inputs on how to resolve this
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.