简体   繁体   中英

How do I convert my code from python3.6 to exe using cxfreeze?

NOTE: Before marking this as duplicate please read the whole post first

I'm trying for hours to convert my python 3.6 code to exe, I've searched everywhere and tried everything, the most helpful place was there: Best method of converting .py to .exe for Python 3.6?

So apparently there are only 3 ways of converting py to exe:

  1. PyInstaller
  2. Py2exe
  3. Cxfreeze

Pyinstaller doesn't support Python 3.6, and py2exe is very outdated.

As for cxfreeze, it sounds like it supports Python 3.6, so that's the route that I've taken.

I've searched everywhere on how to use cxfreeze, unfortunately, all guides that I have found seem to be outdated:

http://cx-freeze.readthedocs.io/en/latest/overview.html this guide for example has three routes, two of which doesn't work (The first gives me a .spec file that i dont know what to do with it and the second gives me an error because i dont have the cxfreeze.util module) and the 3rd is too complicated for my tastes

How do I use cx_freeze? this uses the second route, still it doesn't work

I'm not allowed to comment for some reason, so this isn't really an answer, but for my part I installed cx_Freeze from https://pypi.python.org/pypi/cx_Freeze

When you install it, there's an extra step that's not documented. Using the Windows CMD shell, go to your python installation directory, into the Scripts sub-directory and you will find a few files called cxfreeze...

You need to create the batch file by typing python cxfreeze-postinstall

A file called cxfreeze.bat will be created which you can move into your main python folder or wherever your python program is located.

Then type cxfreeze mypythonprogram.py --target-dir dist

This should create a working exe in the dist directory. However, it doesn't work for me as I get an error in the finder.py file which is part of the cxfreeze installation so I don't know if I've done something wrong or this version is completely buggy.

edit: by commenting out line 561 in the finder.py file (C:\\Python\\Python36-32\\Lib\\site-packages\\cx_Freeze\\finder.py on my system) I was able to run it and Generate the EXE which appears to run OK.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM