在用pyinstaller打包exe時,出現css
pyimod03_importers.py:493: MatplotlibDeprecationWarning: Matplotlib installs where the data is not in the mpl-data subdirectory of the package are deprecated since 3.2 and support for them will be removed two minor releases later. exec(bytecode, module.__dict__) Traceback (most recent call last): File "test_Drawing_day.py", line 10, in <module> import matplotlib.pyplot as plt File "<frozen importlib._bootstrap>", line 971, in _find_and_load File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 665, in _load_unlocked File "d:\anaconda\envs\python36_32\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 493, in exec_module exec(bytecode, module.__dict__) File "matplotlib\__init__.py", line 898, in <module> File "matplotlib\cbook\__init__.py", line 480, in _get_data_path File "matplotlib\__init__.py", line 239, in wrapper File "matplotlib\__init__.py", line 534, in get_data_path File "matplotlib\__init__.py", line 239, in wrapper File "matplotlib\__init__.py", line 566, in _get_data_path RuntimeError: Could not find the matplotlib data files
嘗試了網友說的一系列方法,無果。。。
我發現了錯誤提示裏面的介個:
python
MatplotlibDeprecationWarning: Matplotlib installs where the data is not in the mpl-data subdirectory of the package are deprecated since 3.2 and support for them will be removed two minor releases later.bootstrap
ok,matplotlib3.2之後就把mpl-data分離出去了,我查看了下本身的matplotlib版本app
(python36_32) D:\Anaconda\envs\python36_32\Scripts>pip list Package Version ----------------- ------------------- altgraph 0.17 astroid 2.4.0 certifi 2020.4.5.1 chardet 3.0.4 click 7.1.2 colorama 0.4.3 comtypes 1.1.7 cssselect 1.1.0 cycler 0.10.0 easytrader 0.21.0 easyutils 0.1.7 Flask 1.1.2 future 0.18.2 get 0.0.0 idna 2.10 isort 4.3.21 itsdangerous 1.1.0 Jinja2 2.11.2 joblib 0.15.1 kiwisolver 1.2.0 lazy-object-proxy 1.4.3 lxml 4.5.1 MarkupSafe 1.1.1 matplotlib 3.3.0 ##這裏
行,卸載,重裝(在anaconda prompt裏)spa
pip uninstall matplotlib pip install matplotlib==3.1.1
ok,安裝好新的版本以後從新打包code
pyinstaller -F XXX.py
找到.spec文件
修改 hiddenimports=[‘matplotlib’],
再繼續執行
xml
pyinstaller -F XXX.spec
ok,打包完畢
執行時,會出現warning,可是不影響結果~
bingo~ 但願對你有幫助,我弄了幾個小時了,大哭!!!
blog