Home>

The program is made into an exe using cx_Freeze.

However, when the exe file is started, the following error occurs and it does not start.
I would be very grateful if you could professor.

Error code
ModuleNotFoundError: No module named'scipy.sparse.csgraph._validation'

The program does not import scipy.
The import statement in the program below

# --coding utf-8 -
import fileselect as fs
import pydicom
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.patches as patches
from tqdm import tqdm
import seaborn as sns

The setup file is as follows.

# coding: utf-8
import sys, os
from cx_Freeze import setup, Executable
file_path = input("I want to make an application py:")
if sys.platform == "win32":
    base = None # "Win32GUI" ← GUI enabled
    os.environ['TCL_LIBRARY'] = "C:\\Users\\xxx\\anaconda3\\envs\\v3.6\\tcl\\tcl8.6"
    os.environ['TK_LIBRARY'] = "C:\\Users\\xxx\\anaconda3\\envs\\v3.6\\tcl\\tk8.6"
else:
    base = None # "Win32GUI"
packages = ["matplotlib","numpy",'pydicom','tqdm']
includes = [
    "matplotlib",
    "pydicom",
    "numpy",
    "tqdm"
]
excludes = [
    "PIL",
    "lxml"
]
exe = Executable(
    script=file_path,
    base=base
)
setup(name='main',
      options={
          "build_exe": {
              "packages": packages,
              "includes": includes,
              "excludes": excludes,
          }
      },
      version='0.1',
      description='converter',
      executables=[exe])
  • Answer # 1

    After some trial and error, I managed to solve this problem.
    I tried various methods, so the method described here is not necessarily the correct answer, but I will describe it.

    https://stackoverflow.com/questions/62828976/cx-freeze-error-baseline-image-directory-does-not-exist
    This error has been resolved by performing a downgrade of matplotlib and numpy, as described on this site.