convert .pyw to .exe and have the command line not open - python

I want the command line to not open because a tkinter interface will open.
I am using pyinstaller so it works when python isn't installed. I am using python 3.6.0.
Can I also have it so it is one exe file that doesn't need the other things to run.

To avoid the command line window, add --windowed to your PyInstaller command line.
To create an one-file bundle, add --onefile to your PyInstaller command line.
These are documented in PyInstaller's options. https://pyinstaller.readthedocs.io/en/stable/usage.html#options

Related

Python: Hide console when executing the command line

I have a python script that contains code to execute the command line. I generated .exe file from this script using pyinstaller. This is the command I use to freezes my python script:
pyinstaller --onefile --noconsole sriptName.py
When I open my exe file. The console still opens and shows the output of the command line executed in my script
How can I hide this console?
When you run PyInstaller on your project, does a .SPEC file also appear?
If so, edit the .SPEC file's exe field like so:
exe = EXE(
...,
console=False,
...
)
Then run PyInstaller on the .SPEC file.
If a .SPEC file didn't appear before, try running PyInstaller on your project without any parameters (so just pyinstaller myProgram.py). A .SPEC file should appear and you can edit it as above and then rerun PyInstaller.

.exe built with pyinstaller is only opened while running from cmd

I created a pyinstaller .exe that is built correctly without any mistakes with pyinstaller. When I run it from the cmd, it runs perfectly, but when I double click the .exe file, it does not work. I read that has to do something with PyQt5, but I didn't make it work. This is the creation statement:
pyinstaller --paths
C:\Users\430350\AppData\Local\Programs\Python\Python36\Lib\site-
packages\PyQt5\Qt\bin "path" --hidden-import numpy.core._dtype_ctypes --hidden-
import fix_qt_import_error --icon=icon.ico --noconfirm
Thanks in advance!
Don’t know if it’s the same in Windows. But using pyinstaller in Linux with the -F option (pyinstaller -F file.py) with a PyQt5 project I have to add to the binary file folder .qss and .ui files manually my resource.py file and enclosed png. are not read too. Also did you check the versione you are using ? Python 2 vs 2, 3 vs 3 etc ... v

run python program via clickable desktop icon

I've made a python program using Tkinter(GUI) and I would like to enter it by creating a dedicated icon on my desktop. (I want to send the file to my friend, without him having to install python or any interpreter)
the file is a some-what game that I want to share with friends and family, which are not familiar with coding.
You can simply use Pyinstaller to create a standalone .exe.
Run this from the Windows cmd to create a standalone executable file: pyinstaller.exe --onefile --noconsole --icon=your_image_here.ico app.py
you can install Pyinstaller by using pip
pip install pyinstaller
go to the directory where your file is saved and type:
pyinstaller.exe --onefile --windowed path/to/your/file.py
--onefile (compresses your files into one .exe file)
--windowed (removes the console when you run your file)
path/to/your/file.py (or simply file.py when you want to convert the file in the same directory)
if you have any error using it, remove the --windowed flag and run file.exe on command line to see the error

Create exe files from .py

I have a program with python and it has 3 modules .py.
what should i do to create exe format of this program?
i try this with pyinstaller but thats create exe for my main .py and other .py
modules not contains in it!
Install pyinstaller:
Go to command prompt and type pip install pyinstaller.
Create .exe:
If you want to create a .exe from a .py you need to open your command prompt under the correct directory of the file and type:
pyinstaller —-onefile filename // e.g hello.py as the filename
If it has any basic graphics, type the following in command prompt
pyinstaller —-onefile -w then your file name
This should all work.
If it does not I recommend that you watch this video.

Converting .py to .exe Python 3.6

I have been trying to convert my .py to .exe. Unfortunately, I haven't been successful. After pip install py2exe and using build_exe myscript.py I get multiple errors such as the following:
\...\py2exe\mf3.py", line 120, in import_hook
module = self._gcd_import(name)
\...\py2exe\mf3.py", line 274, in _gcd_import
return self._find_and_load(name)
I don't understand what this mean. Does it mean there is something wrong with my code? (Weird, cause it runs perfectly). Or is it just py2exe that can't do it??
Thanks a lot
I'm not sure about py2exe. I use pyinstaller for creating .exe and it works just fine.
pip install pyinstaller
pyinstaller --onefile filename.py
And that's it. Your .exe is in the dist folder (dist is created automatically by pyinstaller in the directory where the .py file is).
If you don't want a console (if you have a GUI / writing a background process / have no use for I/O or stderr),
pyinstaller --onefile --noconsole filename.py
If you want a customized icon,
pyinstaller --onefile --noconsole -i iconfile filename.py
Edit: The --noconsole switch is ignored in Linux as far as I know.

Categories

Resources