DonikuY
DonikuY

Reputation: 31

ImportError:cannot import name '_methods'

Have created an executable file for my tkinter GUI, bur when trying to run it shows the following error: from.import_methods ImportError:cannot import name '_methods' There seems to be a lot about numpy on the window. Not sure why that is, since I have not imorted numpy on the project.

enter image description here

My setup.py code is:

import sys
import os.path
from cx_Freeze import setup, Executable


#include_files = ['autorun.inf']
PYTHON_INSTALL_DIR = os.path.dirname(os.path.dirname(os.__file__))
os.environ['TCL_LIBRARY'] = os.path.join(PYTHON_INSTALL_DIR, 'tcl', 'tcl8.6')
os.environ['TK_LIBRARY'] = os.path.join(PYTHON_INSTALL_DIR, 'tcl', 'tk8.6')

base = None

if sys.platform == 'win32':
    base = 'Win32GUI'

#os.environ['TCL_LIBRARY'] = r'C:\Users\DonikuY\AppData\Local\Programs\Python\Python36-32\tcl\tcl8.6'
#os.environ['TK_LIBRARY'] = r'C:\Users\DonikuY\AppData\Local\Programs\Python\Python36-32\tcl\tk8.6'

executables = [
    Executable('VacuumPumpGUI.py', base=base)
]


options = {
    'build_exe': {
        'include_files':[
            os.path.join(PYTHON_INSTALL_DIR, 'DLLs', 'tk86t.dll'),
            os.path.join(PYTHON_INSTALL_DIR, 'DLLs', 'tcl86t.dll'),
         ],
    },
}

setup(name="VacuumPumpGUI",
      version="0.1",
      description="Vacuum pump serial GUI.",
      options=options,
      executables=executables
      )

Upvotes: 1

Views: 2206

Answers (1)

Alexander
Alexander

Reputation: 2314

This is a known issue in cx_freeze.

As a workaround you can include in your build options:

    options = {
        'build_exe': {
            'includes':['atexit', 'numpy.core._methods', 'numpy.lib.format'],
       }
   }

Upvotes: 1

Related Questions