cx_Freeze error: baseline image directory does not exist

cx_Freeze error: baseline image directory does not exist

我正在尝试使用 cx_Freeze 库在 Anaconda 虚拟环境中的 Windows 上使用 python 脚本创建一个可执行文件。我试图用 6.1 版来做,但我被困在错误 Intel MKL FATAL ERROR: Cannot load mkl_intel_thread.dll 中。然后我将 cx_Freeze 升级到版本 6.2,这是我在 运行 python setup.py build:

时得到的输出
running build
running build_exe
C:\Users\--\Anaconda3\lib\site-packages\cx_Freeze\finder.py:309: VisibleDeprecationWarning: zmq.eventloop.minitornado is deprecated in pyzmq 14.0 and will be removed.
    Install tornado itself to use zmq with the tornado IOLoop.

  deferredImports, namespace = namespace)
Using TensorFlow backend.
2020-07-10 08:51:47.876748: W tensorflow/stream_executor/platform/default/dso_loader.cc:55] Could not load dynamic library 'cudart64_100.dll'; dlerror: cudart64_100.dll not found
2020-07-10 08:51:47.885038: I tensorflow/stream_executor/cuda/cudart_stub.cc:29] Ignore above cudart dlerror if you do not have a GPU set up on your machine.
C:\Users\--\Anaconda3\lib\site-packages\IPython\html.py:14: ShimWarning: The IPython.html package has been deprecated since IPython 4.0. You should import from notebook instead. IPython.html.widgets has moved to ipywidgets.
  "IPython.html.widgets has moved to ipywidgets.", ShimWarning)
C:\Users\--\Anaconda3\lib\site-packages\IPython\kernel\__init__.py:13: ShimWarning: The IPython.kernel package has been deprecated since IPython 4.0.You should import from ipykernel or jupyter_client instead.
  "You should import from ipykernel or jupyter_client instead.", ShimWarning)
error: The baseline image directory does not exist. This is most likely because the test data is not installed. You may need to install matplotlib from source to get the test data.

以下是文件setup.py的内容:

from cx_Freeze import setup, Executable 
  
exe = Executable(script="mainDefectDetection.py",targetName="Test.exe")
setup(name = "try", version = "0.1", description = "", options = {'build_exe': {'include_files':["../../../../Anaconda3/Library/bin/mkl_intel_thread.dll"]}},executables = [exe])

我尝试重新安装 matplotlib(pip uninstall matpolotlibpip install matplotlib)但没有任何改变。

将 cx_freeze 从版本 6.2 降级到 6.1 使此错误消息消失。现在我在 运行 可执行文件时遇到另一个错误:没有名为 mpl_toolkits.

的模块

当我知道更多时,我会编辑我的答案。我只是想马上回答,所以你知道其他人也有同样的问题。 :)

正在下载 cx_freeze 6.1 对我有用谢谢! 对于没有名为 mpl_toolkits 的模块的错误,您需要告诉 cx_freeze 在哪里可以找到 mpl_toolkits。这可以使用 site.getsitepackages()[1] + '/mpl_toolkits' 来完成,如果不在路径上,您可能必须使用 site.getusersitepackages() 。例如:

    build_exe_options = {"include_files": [(site.getsitepackages()[1] + '/mpl_toolkits', "mpl_toolkits")]}

我原来的回答:https://github.com/marcelotduarte/cx_Freeze/issues/692#issuecomment-657125847

我已经确定了这个问题的根源,就是补丁7ec3eaa。

使用 matplot 示例,我发现 numpy 1.18.3 到 1.19 和 pillow 7.x 存在问题,我正在调查。

目前,它有一个解决方法。

pip install "numpy<1.18.3" "pillow<7"

构建添加 ["matplotlib.tests", "numpy.random._examples"] 以排除或构建:

python setup.py build_exe --excludes=matplotlib.tests,numpy.random._examples

如果您的 setup.py 中有“排除”,请将两个排除的模块添加到其中,设置中的选项是排除的。