Python Forum
How can I make a python script create an EXE?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How can I make a python script create an EXE?
#11
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
Reply
#12
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
Reply
#13
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.
Reply
#14
show the code of your setup file
Reply
#15
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
Reply
#16
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,)]
Reply
#17
I tried it but it gives the exact same error
Reply
#18
you forgot to import build ?

from cx_Freeze import setup, Executable, build
Reply
#19
Yes, but adding it didn't help
Reply
#20
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
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Make entire script run again every 45 mo NDillard 0 291 Jan-23-2024, 09:40 PM
Last Post: NDillard
  Trying to make a board with turtle, nothing happens when running script Quascia 3 607 Nov-01-2023, 03:11 PM
Last Post: deanhystad
  Is there a *.bat DOS batch script to *.py Python Script converter? pstein 3 3,000 Jun-29-2023, 11:57 AM
Last Post: gologica
  Make console show after script was built with Pyinstaller --NOCONSOLE? H84Gabor 0 1,188 May-05-2022, 12:32 PM
Last Post: H84Gabor
  Make my py script work only on 1 compter tomtom 14 3,735 Feb-20-2022, 06:19 PM
Last Post: DPaul
  How to create a Kibana Visualisation with python script? adzadz 0 1,245 Jul-20-2020, 06:41 AM
Last Post: adzadz
  How to kill a bash script running as root from a python script? jc_lafleur 4 5,784 Jun-26-2020, 10:50 PM
Last Post: jc_lafleur
  How to make this function general to create binary numbers? (many nested for loops) dospina 4 4,330 Jun-24-2020, 04:05 AM
Last Post: deanhystad
  Make the script read from any directory falahfakhri 2 2,110 Jun-15-2020, 02:18 PM
Last Post: falahfakhri
  crontab on RHEL7 not calling python script wrapped in shell script benthomson 1 2,247 May-28-2020, 05:27 PM
Last Post: micseydel

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020