Errors being generated when converting python code to exe with cx_freeze

Asked

Viewed 770 times

1

I converted the Tucha.py file to exe following the instructions and with the following setup.py:

from cx_Freeze import setup, Executable

setup(
    name="tucha EXECUTABLE",
    version = "1.0.0",
    description = ".py to .exe",
    executables = [Executable("tucha.py")])
That’s the mistake I’m getting:

    During handling of the above exception, another exception occurred:

  Traceback (most recent call last):
 File "C:\Users\vinic\AppData\Local\Programs\Python\Python35-32\lib\site-packages\cx_Freeze\initscripts\__startup__.py", line 12, in <module>
__import__(name + "__init__")
File "C:\Users\vinic\AppData\Local\Programs\Python\Python35-32\lib\site-packages\cx_Freeze\initscripts\Console.py", line 21, in <module>
scriptModule = __import__(moduleName)
File "tucha.py", line 1, in <module>
File "C:\Users\vinic\AppData\Local\Programs\Python\Python35-32\lib\site-packages\requests\__init__.py", line 63, in <module>
from . import utils
File "C:\Users\vinic\AppData\Local\Programs\Python\Python35-32\lib\site-packages\requests\utils.py", line 24, in <module>
from ._internal_utils import to_native_string
File "C:\Users\vinic\AppData\Local\Programs\Python\Python35-32\lib\site-packages\requests\_internal_utils.py", line 11, in <module>
from .compat import is_py2, builtin_str, str
File "C:\Users\vinic\AppData\Local\Programs\Python\Python35-32\lib\site-packages\requests\compat.py", line 11, in <module>
from .packages import chardet
File "C:\Users\vinic\AppData\Local\Programs\Python\Python35-32\lib\site-packages\requests\packages\__init__.py", line 29, in <module>
import urllib3
ImportError: No module named 'urllib3'

To be honest I did not understand very well what is happening,already searched in google, but the cases that appear did not solve the problem.

1 answer

0

I am creating an answer because I have no reputation to make a comment, I was with a very similar problem and managed to solve after hours searching in stackoverflow.com(In English, no pt I found nothing). I’m new to Python so I’m sorry if I can’t explain it to you the way I do. If there’s a way to publish/edit your Tucha.py code or if you can’t show the code, at least put the header so I can try to help you. I’ll leave here a suggestion of what might help you.

import sys
from cx_Freeze import setup, Executable
import os

build_exe_options = {"packages": ["os","tkinter","tkinter.filedialog","tkinter.messagebox"],
                     "includes": ["reportlab.pdfgen","reportlab.lib.units","subprocess","sqlite3"],
                     }

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

setup(  name = "test",
        version = "1.0",
        description = "test application!",
        options = {"build_exe": build_exe_options},
        executables = [Executable("first.py", base=base,icon="icon.ico")])

In build_exe_options sometimes it is necessary to define libraries that you are using in your script, cx_freeze recognizes some, but others are necessary to add manually.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.