Python Forum
How can I make a python script create an EXE? - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: How can I make a python script create an EXE? (/thread-12350.html)

Pages: 1 2 3


RE: How can I make a python script create an EXE? - ahmed_mokhles - Aug-22-2018

Hello, Axel_Erfurt

I tried doing so but now I get another error:

Error:
error: [Errno 2] No such file or directory: '/home/brian/Dokumente/python_files/ rotateVideo2.py'
from the path given in the error, I'm pretty sure that you coded this in Linux, so can you code another example, but on a windows machine or with windows-compatible code? Plz forgive the Micro$oft fan lol


RE: How can I make a python script create an EXE? - Axel_Erfurt - Aug-22-2018

you must change

Quote:'/home/brian/Dokumente/python_files/rotateVideo2.py'

to the path of your python file

and

Quote:"build_exe": "/tmp/rotateVideo2"

to the path where you want to have the exe.

if you're using windows, change

base = None
to

base = None
if sys.platform == "win32":
    base = "Win32GUI"
It's all in the
cxfreeze documentation



RE: How can I make a python script create an EXE? - ahmed_mokhles - Aug-22-2018

I tried doing so but when I run the EXE that is made it says:

Error:
Traceback(most recent call last): File "C:\Users\<MyUsername>\AppData\Local\Programs\Python\Python36\lib\site-packages\cx_Freeze\initscripts\__startup__.py", line 13, in run module=__import__(name + "__init__") ModuleNotFoundError: No module named <myFilename>
I hope I'm not taking your time but plz help me.


RE: How can I make a python script create an EXE? - Axel_Erfurt - Aug-22-2018

show the code of your setup file


RE: How can I make a python script create an EXE? - ahmed_mokhles - Aug-22-2018

Here:

setup.py:
import sys
from cx_Freeze import setup, Executable

base = None
if sys.platform == "win32":
    base = "Win32GUI"

buildOptions = dict(
    packages = [ 'os', 'time'],
    excludes = [])

executables = [
    Executable(
        "filename.py",
        base = base,)]

setup(
    name='filename',
    version = '2.0',
    description = 'filename',
    options = dict(build_exe = buildOptions),
    executables = executables)

PS: I am using Python 3.6.6 and cx_Freeze 6.0b1
Also I don't know if this is helpful but I'm using Windows 8.1 Single Language


RE: How can I make a python script create an EXE? - Axel_Erfurt - Aug-22-2018

after starting cmd change the working directory to the folder where filename.py is located.

for example

cd C:\yourFolder\

or use the full path to filename.py in your setup.

for example

Executable(
        "C:\yourFolder\filename.py",
        base = base,)]



RE: How can I make a python script create an EXE? - ahmed_mokhles - Aug-22-2018

I tried it but it gives the exact same error


RE: How can I make a python script create an EXE? - Axel_Erfurt - Aug-23-2018

you forgot to import build ?

from cx_Freeze import setup, Executable, build


RE: How can I make a python script create an EXE? - ahmed_mokhles - Aug-23-2018

Yes, but adding it didn't help


RE: How can I make a python script create an EXE? - Axel_Erfurt - Aug-23-2018

then must be something wrong with the path of your file.
I tried your setup with a file and it works.

change /folder/myfile.py to the path you've used.

import os
path = "/folder/myfile.py"
if os.path.exists(path):
    print("True")
else:
    print("False")
does it print True ?

and if you're using python3 you can try

python3 your_setup.py build