本文介绍了安装程序;ModuleNotFoundError:没有名为“sklearn.utils._cython_blas"的模块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的 python 项目有这个导入列表:

I have this import list for my python project:

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')

我用这个命令制作项目的exe文件:

And I use this command to make exe file of the project:

pyinstaller Datamanager.spec

但是当我运行 exe 文件时,它给出了这个错误:

But when I run the exe file it gives this error:

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

我应该向隐藏的导入部分添加哪些其他内容?

What other things should I add to the hidden imports part?

推荐答案

PyInstaller 使用 hook 每个 Python 模块的机制,但有时会遗漏一些内部包,因此您需要手动提供它们.您可以使用 --hidden-import 添加 sklearn 的缺失模块.

PyInstaller uses a hook mechanism for each Python module, but sometimes it misses some internal packages so you need to provide them manually. You can use --hidden-import to add sklearn's missing modules.

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

这篇关于安装程序;ModuleNotFoundError:没有名为“sklearn.utils._cython_blas"的模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-25 07:38