gpt4 book ai didi

python - Pyinstaller - Matplotlib 安装被破坏 - 无法执行 scrypt

转载 作者:行者123 更新时间:2023-12-05 07:09:20 27 4
gpt4 key购买 nike

随时检查我存储库中的代码。

命令尝试:pyinstaller -y 文件.py

发生了什么:我一直在尝试从 .py 制作 .exe 文件。有点大项目,一切正常,但是后来,即使我没有改变任何东西,它也停止了工作。在尝试了数百万种可能的解决方案(更新所有软件包、安装 pyinstaller 的开发版本、修改命令、重新安装 matplotlib、重新启动计算机...)之后,经过大约 5 小时的研究,我决定在这里发布问题。正如我所说,它正在工作......文件目录似乎也很好,原始 .py 代码可以正常工作,即使我将它们放在不同的目录中也是如此。它是多个文件和多个包,全部导入到我正在编译的这个文件(代码)中。运行 .exe 文件后,我收到了这样的输出:(在存储库中)。很抱歉放了截图,而不是代码,但它在关闭前显示了半个发送。

问题几乎肯定是在 matplotlib 中,因为即使我不使用它(在不同的程序中尝试过),但包含 import matplotlib.pyplot as plt,程序也不会启动,作为同一个程序(另一个),没有包含顺利运行。当然,我说的是 .exe 文件,因为 .py 始终有效。

额外信息:我正在使用:Python 32 位,3.8.2。Matplotlib 3.2.1pyinstaller 4.0.dev0+3010fdfaa0(每个包都是最新的,我今天更新了所有 - 02.05.2020)

包含文件和启动 .exe 文件时显示的错误的存储库: https://github.com/jakubedzior/MyPortfolio/tree/master/Koronawirus

(代码):

# Packages that are used in files below
from bs4 import BeautifulSoup
import requests
from pathlib import Path
import csv
import glob
import os
from time import sleep
from pathlib import Path
import numpy as np
import matplotlib.pyplot as plt
from PIL import Image
from datetime import date, timedelta

# My files I import (functions):
from Wiki_update import *
from Csv_edit import *
from Reproduction import *
from Predictions_weekly import *

PS:文件名是Koronawirus.py (/exe)

我从 pyinstaller 获得的输出

PS C:\Users\jakub\Desktop\Programming\Python files\Koronawirus> pyinstaller -y Koronawirus.py                  78 INFO: PyInstaller: 4.0.dev0+3010fdfaa0
78 INFO: Python: 3.8.2
78 INFO: Platform: Windows-10-10.0.18362-SP0
78 INFO: wrote C:\Users\jakub\Desktop\Programming\Python files\Koronawirus\Koronawirus.spec
78 INFO: UPX is not available.
78 INFO: Extending PYTHONPATH with paths
['C:\\Users\\jakub\\Desktop\\Programming\\Python files\\Koronawirus',
'C:\\Users\\jakub\\Desktop\\Programming\\Python files\\Koronawirus']
93 INFO: checking Analysis
93 INFO: Building Analysis because Analysis-00.toc is non existent
93 INFO: Initializing module dependency graph...
93 INFO: Caching module graph hooks...
109 INFO: Analyzing base_library.zip ...
5179 INFO: Processing pre-find module path hook distutils from 'c:\\users\\jakub\\appdata\\local\\programs\\python\\python38-32\\lib\\site-packages\\PyInstaller\\hooks\\pre_find_module_path\\hook-distutils.py'.
5181 INFO: distutils: retargeting to non-venv dir 'c:\\users\\jakub\\appdata\\local\\programs\\python\\python38-32\\lib'
8786 INFO: Caching module dependency graph...
8944 INFO: running Analysis Analysis-00.toc
8966 INFO: Adding Microsoft.Windows.Common-Controls to dependent assemblies of final executable
required by c:\users\jakub\appdata\local\programs\python\python38-32\python.exe
9081 INFO: Analyzing C:\Users\jakub\Desktop\Programming\Python files\Koronawirus\Koronawirus.py
10333 INFO: Processing pre-safe import module hook urllib3.packages.six.moves from 'c:\\users\\jakub\\appdata\\local\\programs\\python\\python38-32\\lib\\site-packages\\PyInstaller\\hooks\\pre_safe_import_module\\hook-urllib3.packages.six.moves.py'.
12449 INFO: Processing pre-find module path hook site from 'c:\\users\\jakub\\appdata\\local\\programs\\python\\python38-32\\lib\\site-packages\\PyInstaller\\hooks\\pre_find_module_path\\hook-site.py'.
12450 INFO: site: retargeting to fake-dir 'c:\\users\\jakub\\appdata\\local\\programs\\python\\python38-32\\lib\\site-packages\\PyInstaller\\fake-modules'
15004 INFO: Processing pre-safe import module hook setuptools.extern.six.moves from 'c:\\users\\jakub\\appdata\\local\\programs\\python\\python38-32\\lib\\site-packages\\PyInstaller\\hooks\\pre_safe_import_module\\hook-setuptools.extern.six.moves.py'.
20241 INFO: Processing pre-safe import module hook six.moves from 'c:\\users\\jakub\\appdata\\local\\programs\\python\\python38-32\\lib\\site-packages\\PyInstaller\\hooks\\pre_safe_import_module\\hook-six.moves.py'.
22307 INFO: Processing module hooks...
22307 INFO: Loading module hook 'hook-certifi.py' from 'c:\\users\\jakub\\appdata\\local\\programs\\python\\python38-32\\lib\\site-packages\\PyInstaller\\hooks'...
22307 INFO: Loading module hook 'hook-Crypto.py' from 'c:\\users\\jakub\\appdata\\local\\programs\\python\\python38-32\\lib\\site-packages\\PyInstaller\\hooks'...
22323 INFO: Loading module hook 'hook-distutils.py' from 'c:\\users\\jakub\\appdata\\local\\programs\\python\\python38-32\\lib\\site-packages\\PyInstaller\\hooks'...
22323 INFO: Loading module hook 'hook-encodings.py' from 'c:\\users\\jakub\\appdata\\local\\programs\\python\\python38-32\\lib\\site-packages\\PyInstaller\\hooks'...
22445 INFO: Loading module hook 'hook-lib2to3.py' from 'c:\\users\\jakub\\appdata\\local\\programs\\python\\python38-32\\lib\\site-packages\\PyInstaller\\hooks'...
22454 INFO: Loading module hook 'hook-lxml.etree.py' from 'c:\\users\\jakub\\appdata\\local\\programs\\python\\python38-32\\lib\\site-packages\\PyInstaller\\hooks'...
22456 INFO: Loading module hook 'hook-matplotlib.backends.py' from 'c:\\users\\jakub\\appdata\\local\\programs\\python\\python38-32\\lib\\site-packages\\PyInstaller\\hooks'...
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "c:\users\jakub\appdata\local\programs\python\python38-32\lib\site-packages\matplotlib\__init__.py", line 1015, in <module>
rcParams = rc_params()
File "c:\users\jakub\appdata\local\programs\python\python38-32\lib\site-packages\matplotlib\__init__.py", line 878, in rc_params
return rc_params_from_file(matplotlib_fname(), fail_on_error)
File "c:\users\jakub\appdata\local\programs\python\python38-32\lib\site-packages\matplotlib\__init__.py", line 731, in matplotlib_fname
for fname in gen_candidates():
File "c:\users\jakub\appdata\local\programs\python\python38-32\lib\site-packages\matplotlib\__init__.py", line 728, in gen_candidates
yield os.path.join(get_configdir(), 'matplotlibrc')
File "c:\users\jakub\appdata\local\programs\python\python38-32\lib\site-packages\matplotlib\__init__.py", line 276, in wrapper
ret = func(**kwargs)
File "c:\users\jakub\appdata\local\programs\python\python38-32\lib\site-packages\matplotlib\__init__.py", line 609, in get_configdir
return _get_config_or_cache_dir(_get_xdg_config_dir())
File "c:\users\jakub\appdata\local\programs\python\python38-32\lib\site-packages\matplotlib\__init__.py", line 562, in _get_xdg_config_dir
return os.environ.get('XDG_CONFIG_HOME') or str(Path.home() / ".config")
AttributeError: type object 'Path' has no attribute 'home'
22929 INFO: Loading module hook 'hook-matplotlib.py' from 'c:\\users\\jakub\\appdata\\local\\programs\\python\\python38-32\\lib\\site-packages\\PyInstaller\\hooks'...
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "c:\users\jakub\appdata\local\programs\python\python38-32\lib\site-packages\matplotlib\__init__.py", line 1015, in <module>
rcParams = rc_params()
File "c:\users\jakub\appdata\local\programs\python\python38-32\lib\site-packages\matplotlib\__init__.py", line 878, in rc_params
return rc_params_from_file(matplotlib_fname(), fail_on_error)
File "c:\users\jakub\appdata\local\programs\python\python38-32\lib\site-packages\matplotlib\__init__.py", line 731, in matplotlib_fname
for fname in gen_candidates():
File "c:\users\jakub\appdata\local\programs\python\python38-32\lib\site-packages\matplotlib\__init__.py", line 728, in gen_candidates
yield os.path.join(get_configdir(), 'matplotlibrc')
File "c:\users\jakub\appdata\local\programs\python\python38-32\lib\site-packages\matplotlib\__init__.py", line 276, in wrapper
ret = func(**kwargs)
File "c:\users\jakub\appdata\local\programs\python\python38-32\lib\site-packages\matplotlib\__init__.py", line 609, in get_configdir
return _get_config_or_cache_dir(_get_xdg_config_dir())
File "c:\users\jakub\appdata\local\programs\python\python38-32\lib\site-packages\matplotlib\__init__.py", line 562, in _get_xdg_config_dir
return os.environ.get('XDG_CONFIG_HOME') or str(Path.home() / ".config")
AttributeError: type object 'Path' has no attribute 'home'
23633 INFO: Loading module hook 'hook-numpy.core.py' from 'c:\\users\\jakub\\appdata\\local\\programs\\python\\python38-32\\lib\\site-packages\\PyInstaller\\hooks'...
23756 INFO: Loading module hook 'hook-numpy.py' from 'c:\\users\\jakub\\appdata\\local\\programs\\python\\python38-32\\lib\\site-packages\\PyInstaller\\hooks'...
23758 INFO: Loading module hook 'hook-PIL.Image.py' from 'c:\\users\\jakub\\appdata\\local\\programs\\python\\python38-32\\lib\\site-packages\\PyInstaller\\hooks'...
24366 INFO: Loading module hook 'hook-PIL.py' from 'c:\\users\\jakub\\appdata\\local\\programs\\python\\python38-32\\lib\\site-packages\\PyInstaller\\hooks'...
24382 INFO: Import to be excluded not found: 'PyQt4'
24382 INFO: Import to be excluded not found: 'PySide'
24382 INFO: Excluding import 'tkinter'
24401 INFO: Removing import of tkinter from module PIL.ImageTk
24404 INFO: Import to be excluded not found: 'FixTk'
24404 INFO: Excluding import 'PyQt5'
24426 INFO: Removing import of PyQt5 from module PIL.ImageQt
24429 INFO: Loading module hook 'hook-PIL.SpiderImagePlugin.py' from 'c:\\users\\jakub\\appdata\\local\\programs\\python\\python38-32\\lib\\site-packages\\PyInstaller\\hooks'...
24429 INFO: Import to be excluded not found: 'FixTk'
24449 INFO: Excluding import 'tkinter'
24463 INFO: Loading module hook 'hook-pkg_resources.py' from 'c:\\users\\jakub\\appdata\\local\\programs\\python\\python38-32\\lib\\site-packages\\PyInstaller\\hooks'...
24987 INFO: Processing pre-safe import module hook win32com from 'c:\\users\\jakub\\appdata\\local\\programs\\python\\python38-32\\lib\\site-packages\\PyInstaller\\hooks\\pre_safe_import_module\\hook-win32com.py'.
Traceback (most recent call last):
File "<string>", line 2, in <module>
ModuleNotFoundError: No module named 'win32com'
25088 INFO: Processing pre-safe import module hook win32com from 'c:\\users\\jakub\\appdata\\local\\programs\\python\\python38-32\\lib\\site-packages\\PyInstaller\\hooks\\pre_safe_import_module\\hook-win32com.py'.
Traceback (most recent call last):
File "<string>", line 2, in <module>
ModuleNotFoundError: No module named 'win32com'
25410 INFO: Excluding import '__main__'
25414 INFO: Removing import of __main__ from module pkg_resources
25415 INFO: Loading module hook 'hook-pycparser.py' from 'c:\\users\\jakub\\appdata\\local\\programs\\python\\python38-32\\lib\\site-packages\\PyInstaller\\hooks'...
25432 INFO: Loading module hook 'hook-setuptools.py' from 'c:\\users\\jakub\\appdata\\local\\programs\\python\\python38-32\\lib\\site-packages\\PyInstaller\\hooks'...
26113 INFO: Loading module hook 'hook-sysconfig.py' from 'c:\\users\\jakub\\appdata\\local\\programs\\python\\python38-32\\lib\\site-packages\\PyInstaller\\hooks'...
26129 INFO: Loading module hook 'hook-xml.dom.domreg.py' from 'c:\\users\\jakub\\appdata\\local\\programs\\python\\python38-32\\lib\\site-packages\\PyInstaller\\hooks'...
26129 INFO: Loading module hook 'hook-xml.etree.cElementTree.py' from 'c:\\users\\jakub\\appdata\\local\\programs\\python\\python38-32\\lib\\site-packages\\PyInstaller\\hooks'...
26144 INFO: Loading module hook 'hook-xml.py' from 'c:\\users\\jakub\\appdata\\local\\programs\\python\\python38-32\\lib\\site-packages\\PyInstaller\\hooks'...
26144 INFO: Loading module hook 'hook-_tkinter.py' from 'c:\\users\\jakub\\appdata\\local\\programs\\python\\python38-32\\lib\\site-packages\\PyInstaller\\hooks'...
26383 INFO: checking Tree
26389 INFO: Building Tree because Tree-00.toc is non existent
26397 INFO: Building Tree Tree-00.toc
26542 INFO: checking Tree
26542 INFO: Building Tree because Tree-01.toc is non existent
26545 INFO: Building Tree Tree-01.toc
26654 INFO: Looking for ctypes DLLs
26732 INFO: Analyzing run-time hooks ...
26732 INFO: Including run-time hook 'c:\\users\\jakub\\appdata\\local\\programs\\python\\python38-32\\lib\\site-packages\\PyInstaller\\hooks\\rthooks\\pyi_rth__tkinter.py'
26748 INFO: Including run-time hook 'c:\\users\\jakub\\appdata\\local\\programs\\python\\python38-32\\lib\\site-packages\\PyInstaller\\hooks\\rthooks\\pyi_rth_multiprocessing.py'
26780 INFO: Including run-time hook 'c:\\users\\jakub\\appdata\\local\\programs\\python\\python38-32\\lib\\site-packages\\PyInstaller\\hooks\\rthooks\\pyi_rth_pkgres.py'
26786 INFO: Including run-time hook 'c:\\users\\jakub\\appdata\\local\\programs\\python\\python38-32\\lib\\site-packages\\PyInstaller\\hooks\\rthooks\\pyi_rth_mplconfig.py'
26797 INFO: Including run-time hook 'c:\\users\\jakub\\appdata\\local\\programs\\python\\python38-32\\lib\\site-packages\\PyInstaller\\hooks\\rthooks\\pyi_rth_mpldata.py'
26814 INFO: Including run-time hook 'c:\\users\\jakub\\appdata\\local\\programs\\python\\python38-32\\lib\\site-packages\\PyInstaller\\hooks\\rthooks\\pyi_rth_certifi.py'
26851 INFO: Looking for dynamic libraries
27717 INFO: Looking for eggs
27717 INFO: Using Python library c:\users\jakub\appdata\local\programs\python\python38-32\python38.dll
27717 INFO: Found binding redirects:
[]
27748 INFO: Warnings written to C:\Users\jakub\Desktop\Programming\Python files\Koronawirus\build\Koronawirus\warn-Koronawirus.txt
28024 INFO: Graph cross-reference written to C:\Users\jakub\Desktop\Programming\Python files\Koronawirus\build\Koronawirus\xref-Koronawirus.html
28169 INFO: checking PYZ
28170 INFO: Building PYZ because PYZ-00.toc is non existent
28172 INFO: Building PYZ (ZlibArchive) C:\Users\jakub\Desktop\Programming\Python files\Koronawirus\build\Koronawirus\PYZ-00.pyz
30186 INFO: Building PYZ (ZlibArchive) C:\Users\jakub\Desktop\Programming\Python files\Koronawirus\build\Koronawirus\PYZ-00.pyz completed successfully.
30223 INFO: checking PKG
30223 INFO: Building PKG because PKG-00.toc is non existent
30226 INFO: Building PKG (CArchive) PKG-00.pkg
30265 INFO: Building PKG (CArchive) PKG-00.pkg completed successfully.
30269 INFO: Bootloader c:\users\jakub\appdata\local\programs\python\python38-32\lib\site-packages\PyInstaller\bootloader\Windows-32bit\run.exe
30277 INFO: checking EXE
30279 INFO: Building EXE because EXE-00.toc is non existent
30284 INFO: Building EXE from EXE-00.toc
30297 INFO: Appending archive to EXE C:\Users\jakub\Desktop\Programming\Python files\Koronawirus\build\Koronawirus\Koronawirus.exe
30322 INFO: Building EXE from EXE-00.toc completed successfully.
30336 INFO: checking COLLECT
30337 INFO: Building COLLECT because COLLECT-00.toc is non existent
30345 INFO: Building COLLECT COLLECT-00.toc
36861 INFO: Building COLLECT COLLECT-00.toc completed successfully.
PS C:\Users\jakub\Desktop\Programming\Python files\Koronawirus>

最佳答案

我遇到了和你完全一样的错误。

执行exe文件时,没有任何错误代码就关闭了

我可以通过删除 anaconda 环境来修复它

如果是anaconda开发环境,替换成普通的python环境。

关于python - Pyinstaller - Matplotlib 安装被破坏 - 无法执行 scrypt,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61635759/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com