简体   繁体   English

安装程序; ModuleNotFoundError:没有名为“sklearn.utils._cython_blas”的模块

[英]Pyinstaller ; ModuleNotFoundError: No module named 'sklearn.utils._cython_blas'

I have this import list for my python project:我的 python 项目有这个导入列表:

import pandas as pd
import time
import sqlalchemy
from sklearn.ensemble import RandomForestClassifier
import pandas as pd
import numpy as np
from sqlalchemy import Column, String, Float, Integer, SmallInteger, MetaData
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import sessionmaker

And this spec file for distribution of the project:这个用于分发项目的规范文件:

import sys
sys.setrecursionlimit(5000)

block_cipher = None


a = Analysis(['DataManager.py'],
             pathex=['E:\\ForexPredictor'],
             binaries=[],
             datas=[],
             hiddenimports=['cython','pymysql','pandas._libs.tslibs.timedeltas','sklearn.neighbors.typedefs','sklearn.utils.typedefs'],
             hookspath=[],
             runtime_hooks=[],
             excludes=[],
             win_no_prefer_redirects=False,
             win_private_assemblies=False,
             cipher=block_cipher,
             noarchive=False)
pyz = PYZ(a.pure, a.zipped_data,
             cipher=block_cipher)
exe = EXE(pyz,
          a.scripts,
          [],
          exclude_binaries=True,
          name='DataManager',
          debug=False,
          bootloader_ignore_signals=False,
          strip=False,
          upx=True,
          console=True )
coll = COLLECT(exe,
               a.binaries,
               a.zipfiles,
               a.datas,
               strip=False,
               upx=True,
               name='DataManager')

And I use this command to make exe file of the project:我使用这个命令来制作项目的 exe 文件:

pyinstaller Datamanager.spec

But when I run the exe file it gives this error:但是当我运行exe文件时,它给出了这个错误:

ModuleNotFoundError: No module named 'sklearn.utils._cython_blas'

What other things should I add to the hidden imports part?我应该向隐藏的导入部分添加哪些其他内容?

PyInstaller uses a hook mechanism for each Python module, but sometimes it misses some internal packages so you need to provide them manually. PyInstaller 对每个 Python 模块使用钩子机制,但有时会漏掉一些内部包,因此需要手动提供。 You can use --hidden-import to add sklearn 's missing modules.您可以使用--hidden-import添加sklearn缺少的模块。

pyinstaller -F --hidden-import="sklearn.utils._cython_blas" --hidden-import="sklearn.neighbors.typedefs" --hidden-import="sklearn.neighbors.quad_tree" --hidden-import="sklearn.tree._utils" Datamanager.py

Add添加

import sklearn.utils._cython_blas

and maybe有可能

import sklearn.neighbors.typedefs
import sklearn.neighbors.quad_tree
import sklearn.tree
import sklearn.tree._utils

to your code.到您的代码。

It is work for my code after i execute this following code :在我执行以下代码后,它适用于我的代码:

pyinstaller --hidden-import="sklearn.utils._cython_blas" --hidden-import="sklearn.neighbors.typedefs" --hidden-import="sklearn.neighbors.quad_tree" --hidden-import="sklearn.tree._utils" --hidden-import="sklearn.neighbors._typedefs" --hidden-import="sklearn.utils._weight_vector" --hidden-import="sklearn.neighbors._quad_tree" namepythonfile.py pyinstaller --hidden-import="sklearn.utils._cython_blas" --hidden-import="sklearn.neighbors.typedefs" --hidden-import="sklearn.neighbors.quad_tree" --hidden-import="sklearn.tree ._utils" --hidden-import="sklearn.neighbors._typedefs" --hidden-import="sklearn.utils._weight_vector" --hidden-import="sklearn.neighbors._quad_tree" namepythonfile.py

Try to add all the module to hidden import code to be successful尝试将所有模块添加到隐藏导入代码中即可成功

Have you tried reading the documentation regarding the use of .spec-files?您是否尝试阅读有关使用 .spec 文件的文档? https://pyinstaller.readthedocs.io/en/stable/spec-files.html#using-spec-files https://pyinstaller.readthedocs.io/en/stable/spec-files.html#using-spec-files

I don't know if it's the issue, but where is your *.py-file in the command for creating an .exe-file?我不知道这是否是问题所在,但是在用于创建 .exe 文件的命令中您的 *.py 文件在哪里? As far as I know you have to give pyinstaller a .py-file for it to create a program.据我所知,您必须为 pyinstaller 提供一个 .py 文件才能创建程序。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 ModuleNotFoundError:没有名为“sklearn.utils._joblib”的模块 - ModuleNotFoundError: No module named 'sklearn.utils._joblib' ModuleNotFoundError:没有名为“sklearn.utils._testing”的模块 - ModuleNotFoundError: No Module named 'sklearn.utils._testing' ModuleNotFoundError:没有名为“utils”的模块 - ModuleNotFoundError: No module named 'utils' ModuleNotFoundError:没有名为“Cython”的模块 - ModuleNotFoundError: No module named 'Cython' 无法与GaussianNB配合-ModuleNotFoundError:没有名为“ sklearn.utils._pprint”的模块 - unable to fit with GaussianNB - ModuleNotFoundError: No module named 'sklearn.utils._pprint' ModuleNotFoundError:没有名为 utils 的模块 - ModuleNotFoundError: No module named utils modulenotfounderror:没有名为“ sklearn”的模块 - modulenotfounderror : no module named 'sklearn' ModuleNotFoundError:没有名为“sklearn”的模块 - ModuleNotFoundError: No module named 'sklearn' Pyinstaller和sklearn.ensemble:'ModuleNotFoundError:没有名为'sklearn.neighbors.quad_tree'的模块[2760]' - Pyinstaller and sklearn.ensemble: 'ModuleNotFoundError: No module named 'sklearn.neighbors.quad_tree' [2760]' PyInstaller:ModuleNotFoundError:没有名为“编码”的模块 - PyInstaller: ModuleNotFoundError: No module named 'encodings'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM