找不到模块错误,没有名为mpl_toolkits的模块

时间:2019-06-20 10:51:28

标签: python charts 3d projection

我遇到了一个错误modulenotfounderror没有名为mpl_tookits的模块。

当我在pycharm中执行代码时,一切正常,但是当我使用cz_freeze将其转换为.exe可执行文件时,将引发上述错误。到目前为止,我已经尝试过下面的代码。请帮助我解决这个问题。 帮助将不胜感激。

main.py

   from mpl_toolkits.mplot3d import axes3d
   import matplotlib.pyplot as plt
   from matplotlib import cm

   fig = plt.figure()
   ax = fig.add_subplot(111, projection='3d')
   X, Y, Z = axes3d.get_test_data(0.05)
   cset = ax.contour(X, Y, Z, cmap=cm.coolwarm)
   ax.clabel(cset, fontsize=9, inline=1)

   plt.show()

setup.py

import sys
import os
import os.path
import numpy
import importlib


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
console = False
if sys.platform == 'win32':
    base = "Win32GUI"


executables = [Executable("main.py",base = base,icon='logo.ico')]
additional_mods = ['numpy.core._methods', 'numpy.lib.format']
packages = ["idna"]
options = {
    'build_exe': {
        'packages':packages,
    'include_files':[
            os.path.join(PYTHON_INSTALL_DIR, 'DLLs', 'tk86t.dll'),
            os.path.join(PYTHON_INSTALL_DIR, 'DLLs', 'tcl86t.dll'),
         ],
        'includes':additional_mods
    },

}

setup(
    name = "projectname",
    options = options,
    version = "1.0",
    description = 'Material Generator',
    executables = executables
)

0 个答案:

没有答案