use cx_freeze with mysql-connector
Question: I'm trying to make an exe program from a fully functional python 3.4 script,
but I can't embed the dependencies about official mysql connector. This is a
sample code with the problem:

    
    
    import mysql.connector
    from settings import *
    
    connLocal  = mysql.connector.connect( host   =  DB_CRM_HOST,
                                          user   =  DB_CRM_USER,
                                          passwd =  DB_CRM_PASS,
                                          db     =  DB_CRM_DB )
    cursorLocal = connLocal.cursor ()
    sqlStr = "SELECT * FROM Users"
    cursorLocal.execute( sqlStr)
    for row in  cursorLocal.fetchall():
        print(row)
    

and this is my setup script:

    
    
    '''script per il setup'''
    import sys
    from cx_Freeze import setup, Executable
    
    EXCLUDES = ['_ssl',  # Exclude _ssl
                'pyreadline', 'difflib', 'doctest', 'locale',
                'optparse', 'pickle', 'calendar']  # Exclude standard library
    PACKAGES = []
    INCLUDES = []
    SCRIPT_NAME = "sync_crm2web.py"
    EXE_NAME = "sync_crm2web.exe"
    PRJ_NAME = "sync_crm2web"
    VERSION = 1.0
    AUTHOR = "Antonio"
    DESCRIPTION = "Sincronizzazione crm sito internet"
    BASE = "Console" #"Win32GUI"
    
    #------------------------------------------------------------------------------
    BUILD_EXE_OPTIONS = {"packages": PACKAGES,
                         "excludes": EXCLUDES,
                         "includes": INCLUDES,
                         "path": sys.path,
                         'append_script_to_exe':False,
                         'build_exe':"dist/bin",
                         'compressed':True,
                         'copy_dependent_files':True,
                         'create_shared_zip':True,
                         'include_in_shared_zip':True,
                         'optimize':2,}
    
    EXE = Executable(script=SCRIPT_NAME,
                     base=BASE,
                     compress=True,
                     targetDir="dist",
                     targetName=EXE_NAME,
                     initScript=None,
                     copyDependentFiles=True,
                     appendScriptToExe=True,
                     appendScriptToLibrary=False,
    )
    
    setup(name=PRJ_NAME,
          version=VERSION,
          author=AUTHOR,
          description=DESCRIPTION,
          options={"build_exe": BUILD_EXE_OPTIONS},
          executables=[EXE])
    

also trying forcing PACKAGES = [], INCLUDES = [] with combination of mysql,
mysql-connector, mysql.connector seem not to work.

I always obtain:

    
    
    Traceback (most recent call last):
      File "C:\Python34\lib\site-packages\cx_Freeze\initscripts\Console.py", line 27, in <module>
        exec(code, m.__dict__)
      File "sync_crm2web.py", line 1, in <module>
      File "c:\python\32-bit\3.4\lib\importlib\_bootstrap.py", line 2214, in _find_and_load
      File "c:\python\32-bit\3.4\lib\importlib\_bootstrap.py", line 2189, in _find_and_load_unlocked
      File "c:\python\32-bit\3.4\lib\importlib\_bootstrap.py", line 321, in _call_with_frames_removed
      File "c:\python\32-bit\3.4\lib\importlib\_bootstrap.py", line 2214, in _find_and_load
      File "c:\python\32-bit\3.4\lib\importlib\_bootstrap.py", line 2201, in _find_and_load_unlocked
    ImportError: No module named 'mysql'
    

Can someone help me? full cx_freeze log here <http://pastebin.com/S3TMzAnB>


Answer: Solved using input from [Cx-Freeze Error - Python
34](http://stackoverflow.com/questions/23920073/cx-freeze-error-python-34) \-
[www.lfd.uci.edu/~gohlke/pythonlibs](http://www.lfd.uci.edu/~gohlke/pythonlibs/#cx_freeze)
so I've installed cx_Freeze from this installer and not from PIP.

After that I've commented the needed **_ssl** module and place all library
('build_exe' property) in the same folder of the executable.

    
    
    '''script per il setup'''
    import sys
    from cx_Freeze import setup, Executable
    
    EXCLUDES = [#'_ssl',  # !!!! COMMENTED !!!!
                'pyreadline', 'difflib', 'doctest', 'locale',
                'optparse', 'pickle', 'calendar']  # Exclude standard library
    PACKAGES = []
    INCLUDES = []
    SCRIPT_NAME = "sync_crm2web.py"
    EXE_NAME = "sync_crm2web.exe"
    PRJ_NAME = "sync_crm2web"
    VERSION = 1.0
    AUTHOR = "Antonio"
    DESCRIPTION = "Sincronizzazione crm sito internet"
    BASE = "Console" #"Win32GUI"
    
    #------------------------------------------------------------------------------
    BUILD_EXE_OPTIONS = {"packages": PACKAGES,
                         "excludes": EXCLUDES,
                         "includes": INCLUDES,
                         "path": sys.path,
                         'append_script_to_exe':False,
                         'build_exe':"dist", # !!!! BEFORE WAS dist/bin !!!!
                         'compressed':True,
                         'copy_dependent_files':True,
                         'create_shared_zip':True,
                         'include_in_shared_zip':True,
                         'optimize':2,}
    
    EXE = Executable(script=SCRIPT_NAME,
                     base=BASE,
                     compress=True,
                     targetDir="dist",
                     targetName=EXE_NAME,
                     initScript=None,
                     copyDependentFiles=True,
                     appendScriptToExe=True,
                     appendScriptToLibrary=False,
    )
    
    setup(name=PRJ_NAME,
          version=VERSION,
          author=AUTHOR,
          description=DESCRIPTION,
          options={"build_exe": BUILD_EXE_OPTIONS},
          executables=[EXE])
    

