如何排除特定进口

How to exclude specific imports

我在排除 pandas 时是否遗漏了什么?好像把这个放在main.exe里不管怎样

我尝试添加:

excludes=['C:\Users\da\AppData\Local\Programs\Python\Python\Lib\site-packages\pandas'],

到规范文件。

以及

pyinstaller --onefile --exclude pandas
in command line

运气不好。我在这里遗漏了什么还是更好地创建一个单独的 python 安装虚拟环境并仅使用需要的模块与 pyinstaller?或者甚至分开 python 并在需要时交换。

# -*- mode: python -*-

block_cipher = None


a = Analysis(['Main.py'],
             pathex=[],
             binaries=[],
             datas=[],
             hiddenimports=[],
             hookspath=[],
             runtime_hooks=[],
             excludes=['C:\Users\da\AppData\Local\Programs\Python\Python\Lib\site-packages\pandas'],
             win_no_prefer_redirects=False,
             win_private_assemblies=False,
             cipher=block_cipher)
pyz = PYZ(a.pure, a.zipped_data,
             cipher=block_cipher)
exe = EXE(pyz,
          a.scripts,
          exclude_binaries=True,
          name='win',
          debug=False,
          strip=False,
          upx=True,
          console=True)
coll = COLLECT(exe,
               a.binaries,
               a.zipfiles,
               a.datas,
               strip=False,
               upx=True,
               name='win')

"Am I missing something here or is better to create a separate virtual environment of python installation and use only needed modules with pyinstaller? Or even separate python and swap when needed."

同意。而不是排除模块 我强烈建议创建一个虚拟环境或 python 3.