簡體   English   中英

使用 pyinstaller 后出現“ModuleNotFoundError: No module named 'arcade'”

[英]"ModuleNotFoundError: No module named 'arcade'" after using pyinstaller

該腳本運行良好,但使用 pyinstaller 編譯時會在運行時引發錯誤:

Traceback (most recent call last):
  File "poples.py", line 3, in <module>
ModuleNotFoundError: No module named 'arcade'
[5316] Failed to execute script 'poples' due to unhandled exception!

Arcade(latest version:2.6.15)  is installed on my python folder:
    C:\Users\Sarp\AppData\Local\Programs\Python\Python310\Lib\site-packages
as well as installed in my project virtual enviroment folder

到目前為止我做了什么:

  • 重新開始:刪除 venv 文件夾並重新創建新的

  • 使用 pycharms requirements.txt,我再次重新安裝了所有必需的包

  • 我在我的項目文件夾中運行pyi-makespec

     pyi-makespec --onefile --windowed --icon=icon.ico poples.py
  • 編輯規范文件行: hiddenimports=[], to hiddenimports=['arcade'], and console=False to console=True (查看運行時錯誤)

    它看起來像這樣:

     block_cipher = None a = Analysis( ['poples.py'], pathex=[], binaries=[], datas=[], hiddenimports=['arcade'], hookspath=[], hooksconfig={}, 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, a.binaries, a.zipfiles, a.datas, [], name='poples', debug=False, bootloader_ignore_signals=False, strip=False, upx=True, upx_exclude=[], runtime_tmpdir=None, console=True, disable_windowed_traceback=False, argv_emulation=False, target_arch=None, codesign_identity=None, entitlements_file=None, icon='icon.ico', )
  • 在我的項目文件夾 pyinstaller poples.spec 中運行 pyinstaller

  • 通過命令提示符運行腳本

  • 出錯了

已解決:我總是將 pyinstaller.exe 復制到我的項目文件夾中,然后從那里運行。 它總是適用於我的其他項目。但是當我從這個項目文件夾中刪除 pyinstaller 並運行它時,它就完成了工作。 但我仍然不知道為什么會這樣。 也許街機不喜歡我項目文件夾中的 pyinstaller。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM