1

I got the next problem. During the last 3 months, I was building an application in Python 3.5 to test luminaries. For this application I used the next libraries, "tkinter", "sys", "threading", "os", "time", "shutil" that are included on the main Python 3.5 interpreter. In addition to this system libraries, I use "pyserial", "PyGreSQL", "PIL", "win32com", and "qrcode".

The program will be used on many PCs, so I need to compile all the code to make a fully functional application in every PC that is installed. I tried using PyInstaller, but it not works for me, for a reason that I don't understand, I can not make it work.

So, due that I think there is no more way to "compile" my python 3.5 app to an exe (all the solutions only works in Python 2.x), I think the solution is only two ways to resolve.

The first solution is, to copy the Python35 folder, that got all the libraries that I have already installed into another PC(this is because every single that I installed give me problems at the installation, specially pygresql) and if I can make an "Installer" that overwrite this Python35 folder into the new PC and create a link icon to the desktop that runs the .py script. (Simulate an APP is installed).

Or the second solution, rewrite all code into 2.x syntax and try installing again libraries for python 2.x, and make all the code functional again...

Which one do you recommend me... Or if you know any way that I could do this... I would be very grateful if you help me.

Thanks!

1 Answers1

0

I've used CX_Freeze on my programs in the past, so far I have only used it with python 3.4.3, but I see no reason why it shouldn't work with python 3.5.

You can also install it with pip:

pip install CX_Freeze

See here for a tutorial.

I'm out at the moment, so I'll comment the code I use when I next have my computer.

I hope this helps.

EDIT:

Here is a version of the code (for batch):

set PATH=%PATH%;C:\Python34\ python "setup.py" build pause

to use this code, you will need to make a setup script pointing to your program, an example is below:

import sys
from cx_Freeze import setup, Executable

# Dependencies are automatically detected, but it might need fine tuning. This example will include the os package, and omit the tkinter package
build_exe_options = {"packages": ["os"], "excludes": ["tkinter"]}

# GUI applications require a different base on Windows (the default is for a
# console application).
base = None
if sys.platform == "win32":
    base = "Win32GUI"

setup(  name = "test",
        version = "0.1",
        description = "My GUI application!",
        options = {"build_exe": build_exe_options},
        executables = [Executable("test.py", base=base)])

EDIT2:

Although the above code does work, the code I use is:

cxfreeze "%cd%\File.py" --target-dir "%cd%\File\"

AvahW
  • 2,083
  • 3
  • 24
  • 30
  • I will try to use cx_freeze to do it the "compilation". In addition I will wait for your code and hope you could post as soon as possible. Thanks – David González Blazman May 20 '16 at 07:08
  • Ok, so, I was looking and cx_freeze only works on Python 3.4... So... I think I don't need to rewrite the code but, instead of this, I will need to reinstall the python interpreter and every library adapted to this version of python... – David González Blazman May 20 '16 at 07:18
  • @DavidGonzálezBlazman See my edit for the code. It should work, but as I mentioned in the edit, I won't get home, or access to a computer that isn't my phone, for a few more hours. – AvahW May 20 '16 at 10:18