2017-06-14 119 views
0

已经创建了一个可执行文件我Tkinter的GUI,钻试图运行它显示了以下错误时: from.import_methods导入错误:无法导入名称“_methods” 似乎有一个很多关于窗户上的numpy。不知道这是为什么,因为我没有在项目上混淆不清。导入错误:无法导入名称“_methods”

enter image description here

我setup.py代码:

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 
    ) 
+1

请不要张贴堆栈跟踪的屏幕截图。花时间复制并粘贴并正确格式化。 –

+0

那么最快的解决方案将是卸载numpy,看看这是否有窍门。然后,您需要花时间阅读文档以确保正确使用冻结。我没有使用自己的冻结,但我会冻结图像,不应该对未导入的库进行任何操作。 –

+0

也看看这篇文章[如何创建 - exe文件在python-using-cx-freeze](https://stackoverflow.com/questions/17798128/how-to-create-exe-文件中的Python-使用-CX-冻结)。 –

回答

0

这是一个cx_freeze known issue

作为一种变通方法,您可以在您的编译选项:

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