1

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
      )
DavidG
  • 24,279
  • 14
  • 89
  • 82
DonikuY
  • 31
  • 8
  • 1
    Please don't post a screenshot of the stack trace. Take the time to copy and paste and properly format it. – Bryan Oakley Jun 14 '17 at 15:37
  • Well the quickest solution would to be to uninstall numpy and see if that does the trick. Then you need to take the time to read the documentation to make sure you are using freeze correctly. I have not used freeze myself but I would imaging that freeze should not have to do anything with libraries that are not imported. – Mike - SMT Jun 14 '17 at 16:01
  • Also take a look at this post [how-to-create-exe-file-in-python-using-cx-freeze](https://stackoverflow.com/questions/17798128/how-to-create-exe-file-in-python-using-cx-freeze). – Mike - SMT Jun 14 '17 at 16:03
  • Thanks, I will have a look at removing numpy and the other post and inform you. – DonikuY Jun 15 '17 at 07:01
  • Hi I have removed numpy and still does not work. There seems to be an issue with matplotlib library as the executable builds and runs well without the graphs. Any ideas? – DonikuY Jul 31 '17 at 08:13

1 Answers1

1

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'],
       }
   }
Alexander
  • 2,174
  • 3
  • 16
  • 25