python - pandas导入时exe文件运行失败

标签 python pandas numpy exe

exe 文件启动但崩溃并显示 ModuleNotFoundError: No module named 'numpy.random.common'

我使用pyinstaller --onefile hello.py --hidden-import pandas和 .exe 文件失败。 我尝试通过添加路径来更改规范文件 pandas ,但是.exe文件仍然失败。

hello.py文件的内容:

import os
input("before loading pandas")
import pandas
print ("hello")
input('waiting for keyboard input')

规范文件的内容:

# -*- mode: python ; coding: utf-8 -*-

block_cipher = None

def get_pandas_path():
    import pandas
    pandas_path=pandas.__path__[0]
    return pandas_path


a = Analysis(['CreateExcelSAList.py'],
             pathex=['D:\\OneDrive - Ardovlam NV\\15. Python\\hello'],
             binaries=[],
             datas=[],
             hiddenimports=[],
             hookspath=[],
             runtime_hooks=[],
             excludes=[],
             win_no_prefer_redirects=False,
             win_private_assemblies=False,
             cipher=block_cipher,
             noarchive=False)
dict_tree=Tree(get_pandas_path(),prefix='pandas',excludes=["*.pyc"])
a.datas+=dict_tree
a.binaries=filter(lambda x:'pandas' not in x[0], a.binaries)

pyz = PYZ(a.pure, a.zipped_data,
             cipher=block_cipher)
exe = EXE(pyz,
          a.scripts,
          a.binaries,
          a.zipfiles,
          a.datas,
          [],
          name='hello',
          debug=False,
          bootloader_ignore_signals=False,
          strip=False,
          upx=True,
          upx_exclude=[],
          runtime_tmpdir=None,
          console=True )
scoll=COLLECT(exe,
            a.binaries,
            a.zipfiles,
            a.datas,
            strip=None,
            upx=True,
            name='hello')

最佳答案

似乎是一个已知错误。请查看:https://github.com/numpy/numpy/issues/14163 。 stackoverflow上有引用解决方案。

关于python - pandas导入时exe文件运行失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57535602/

相关文章:

python - Pandas - 迭代数据框行并更新 df(一行代码)

python - "list index out of range"异常(Python3)

python - 根据多个日期条件过滤 Dataframe

python - 可见弃用警告 : using a non-integer number instead of an integer will result in an error in the future

python - 神经网络训练平台中的梯度下降

python - Selenium python - 元素在点不可点击

python - 从 python 脚本运行 shell 命令\n

Pandas DataFrame n-large,随组变化

pandas - 如何显示 Pandas 列中某个值的最后一次出现?

pandas - 删除循环遍历 numpy 数组的要求