i made a python script(flask) that use html and generate a local host link to open my website i also imported some deep learning models to my project what i want is i want to make an exe file that gives me the output is the local host link so i used this command to make it
pyinstaller --onefile main.py
but when i run my exe file it gives me this error
no module named cv2
i also tried this command
pyinstaller spec_an_API.py --onefile --add-data "templates";"templates" --add-data "static";"static"
but same problem
not that my program has no errors i tried to run it from pycharm and it works well
Related
AssertionError: Failed to determine matplotlib's data directory!
Im not using maptolib anywhere and there is another error assiciated with it
File "C:\Python310\lib\site-packages\matplotlib\colors.py", line 51, in <module>
from PIL import Image
ModuleNotFoundError: No module named 'PIL'
My command
pyinstaller --noconfirm --onefile -w --console --name "Project1" --add-data "C:/Users/user/Desktop/bot/app.py;." --add-data "C:/Users/user/Desktop/bot/czgen.py;." --add-data "C:/Users/user/Desktop/bot/sk.py;." --add-data "C:/Users/user/Desktop/bot/site.py;." --hidden-import "colorama" "C:/Users/user/Desktop/bot/main.py"
Any ideas?
i think one of the modules you used needs matplotlib, so check if everything works. otherwise, i would suggest to clear out the virtual enviroment and downloading everything back. this way the issue will be inside of the code and not in pyinstaller, therefore it'll be easier to debug and find the issue.
I'm trying to build an exe file from a python game using PyBox2D and Pyglet.
When I build the exe there occurs an error that a module cannot be imported:
Unable to import the back-end pyglet: module 'gui.backends' has no attribute 'pyglet_framework'
I guess this happens because this file only gets imported indirectly/hidden from another file with __import__()
This is my project hierarchy:
I've tried to add the file to pyinstaller on multiple ways. From the directory /SpaceJam/building I've tried calling:
pyinstaller.exe --onefile "../game/spacejam.py" --hidden-import="gui/framework/backends/pyglet_framework.py"
pyinstaller.exe --onefile "../game/spacejam.py" --hidden-import="../gui/framework/backends/pyglet_framework.py"
pyinstaller.exe --onefile "../game/spacejam.py" --hidden-import="../gui/framework/backends/pyglet_framework"
pyinstaller.exe --onefile "../game/spacejam.py" --hidden-import="../gui/framework/backends/*"
but none of that seemed to change anything in the error message.
I feel like I'm missing something obvious. Does somebody have an idea what I might be doing wrong or why the --hidden-import argument doesn't seem to work?
That argument expects a module name, not a filesystem path. How would you import it?
I'm not totally clear on how your project is set up, but try
--hidden-import gui.backends.pyglet_framework
I have created my python script and linked in tkinter UI both .py files are running fine when i ran it visual studio code. But I have converted tkinter UI .py file to .exe file to run my python script in executable file. I have successfuly converted the executable file. But when i run through the executable file(Application) No Such file in directory error coming
'c:\users\username\appdate\local\temp_MEI16402\myprogram.py' no such file or directory
This is temp location
But i have my UI.py,myprogram.py in same location
how to solve this error. Please help.
To import myprogram.py into UI.py you can do this:
import myprogram.py
The when you build it into an .exe file with pyinstaller you can add the --onefile option to build both scripts into one file. Here's an example:
pyinstaller --onefile UI.py
I wrote a simple code in python/pygame, and the game was running fine in both sublime text and cmd, but when I tried to make it a exe file pyinstaller --onefile version2.py, I got an error and I don't know what is the problem ?
Well bro, I don't know if I will be helpfull to you know after 6 days, I am having 2 solutions for you which worked for me today.
Disable Antivirus OR put that folder in which you are building app.exe to Exception, like I have done below [Mandatory Process].
Dont' run pyinstaller command from the directory where app.py application is present.
a) Get out from that directory/folder
b) Create new directory/folder
c) Enter that directory and start cmd in that directory/folder by pressing (shift + MouseRightClick )
d) And then run the command
pyinstaller --name "MyApp" "python script file path of which you want to create .exe file"
Where "MyApp" is the name which you want to give to the file after it is build successfully
For Example
pyinstaller --name "FileRenamer" "G:\data\python\Project\Bunch File Renamer\rename.py"
Try to disable the anti-virus, that worked for me
I downloaded pyinstaller and pywin32 and placed both in the Python32-35 folder
I then put a copy of the gui program(Homework.py) I coded into the Scripts folder that is located in the previous folder
Now I when I open a cmd window and enter the code
pyinstaller--onefile --windowed Homework.py
I am receiving the error in cmd saying
'pyinstaller--onefile' is not recognized as an internal or external command,
operable program or batch file.
use this command to call the module directly:
python -m PyInstaller --onefile --windowed --name="fileName" Homework.py