简体   繁体   中英

cx_Freeze: Python error in main script - ModuleNotFoundError: No module named 'scipy.spatial.ckdtree

I encounter the following error after cx_Freeze has built an executable based on my Python code.

C:\Users\MAIN\Desktop\NEW\build\exe.win-amd64-3.7>GUI-Peak-Analysis
Traceback (most recent call last):
File "C:\Users\MAIN\AppData\Local\Programs\Python\Python37\lib\site-packages\cx_Freeze\initscripts\__startup__.py", line 40, in run
module.run()
File "C:\Users\MAIN\AppData\Local\Programs\Python\Python37\lib\site-packages\cx_Freeze\initscripts\Console.py", line 37, in run
exec(code, {'__name__': '__main__'})
File "GUI-Peak-Analysis.py", line 6, in <module>
File "C:\Users\MAIN\Desktop\NEW\Goldindec.py", line 11, in <module>
from scipy.interpolate import interp1d  ## to smooth spectrum
File "C:\Users\MAIN\AppData\Local\Programs\Python\Python37\lib\site-packages\scipy\interpolate\__init__.py", line 167, in <module>
from .interpolate import *
File "C:\Users\MAIN\AppData\Local\Programs\Python\Python37\lib\site-packages\scipy\interpolate\interpolate.py", line 26, in <module>
from .interpnd import _ndim_coords_from_arrays
File "interpnd.pyx", line 1, in init scipy.interpolate.interpnd
File "C:\Users\MAIN\AppData\Local\Programs\Python\Python37\lib\site-packages\scipy\spatial\__init__.py", line 100, in <module>
from .ckdtree import *
ModuleNotFoundError: No module named 'scipy.spatial.ckdtree'

I have followed instructions on various websites including the cx_Freeze FAQ on how to solve the problem. I tried downloading scipy modules from https://github.com/scipy/scipy/releases (scipy-1.4.1.zip) and including the scipy.spatial.ckdtree module during building the program with cx_Freeze. However, when I browse the folder, I only see C and/or C++ source files and headers

Here is the code of my setup file:

import sys
from cx_Freeze import setup, Executable

# Dependencies are automatically detected, but it might need fine tuning.
build_exe_options = {"packages": ["os", "astropy", "matplotlib", "numpy", "pyqt5", "scipy"], 
                     "excludes": ["tkinter"]}

# GUI applications require a different base on Windows (the default is for a
# console application).
base = None
#if sys.platform == "win32":
#    base = "Win32GUI"

setup(  name = "GUI-Peak-Analysis",
        version = "0.1",
        description = "My GUI application!",
        options = {"build_exe": build_exe_options},
        executables = [Executable("GUI-Peak-Analysis.py", base=base)])

尝试执行一行 Python 脚本(如果失败,请执行 pip install scipy 并重做): from scipy.spatial.ckdtree import *

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM