簡體   English   中英

PyInstaller錯誤“ Python未作為框架安裝”

[英]PyInstaller error “Python not installed as framework”

我正在MacOS上工作,並且嘗試使用PyInstaller將腳本分發給一些非技術同事。 該腳本被想象性地稱為script_V1.py並且可以正常運行。

到目前為止,我的PANDAS和SCIPY出現了問題,但是似乎可以通過以下命令解決

pyinstaller --onefile --hidden-import pandas._libs.tslibs.timedeltas --hidden-import scipy._lib.messagestream script_V1.py

但是,我現在遇到了另一個錯誤(我將在下面發布完整錯誤)

RuntimeError: Python is not installed as a framework. The Mac OS X 
backend will not be able to function correctly if Python is not
installed as a framework. See the Python documentation for more 
information on installing Python as a framework on Mac OS X. Please
either reinstall Python as a framework, or try one of the other 
backends. If you are using (Ana)Conda please install python.app and 
replace the use of 'python' with 'pythonw'. See 'Working with 
Matplotlib on OSX' in the Matplotlib FAQ for more information.

我已經在Stack Exchange上的類似問題中嘗試過該解決方案:

matplotlib Python的安裝問題

但是,我認為導入語句在腳本本身內不起作用實際上是一個不同的問題。 就我而言,如果我將腳本作為.py腳本運行,則可以正常工作。 無論如何,添加建議的文件不會更改錯誤消息。 我對此並不陌生,似乎真的在PyInstaller上掙扎(比python本身更多),因此任何幫助都值得贊賞。

完整的錯誤消息是(為清楚起見,我添加了換行符)

Traceback (most recent call last):
File "script_V1.py", line 5, in <module>
import matplotlib.pyplot as plt
File "<frozen importlib._bootstrap>", line 2237, in _find_and_load
File "<frozen importlib._bootstrap>", line 2226, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 1200, in _load_unlocked
File "<frozen importlib._bootstrap>", line 1129, in _exec
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/PyInstaller/loader/pyimod03_importers.py", line 631, in exec_module
exec(bytecode, module.__dict__)
File "site-packages/matplotlib/pyplot.py", line 115, in <module>
File "site-packages/matplotlib/backends/__init__.py", line 62, in pylab_setup
File "<frozen importlib._bootstrap>", line 2237, in _find_and_load
File "<frozen importlib._bootstrap>", line 2226, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 1200, in _load_unlocked
File "<frozen importlib._bootstrap>", line 1129, in _exec
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/PyInstaller/loader/pyimod03_importers.py", line 631, in exec_module
exec(bytecode, module.__dict__)
File "site-packages/matplotlib/backends/backend_macosx.py", line 17, in <module>
File "<frozen importlib._bootstrap>", line 2237, in _find_and_load
File "<frozen importlib._bootstrap>", line 2226, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 1191, in _load_unlocked
File "<frozen importlib._bootstrap>", line 1161, in _load_backward_compatible
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/PyInstaller/loader/pyimod03_importers.py", line 714, in load_module
module = loader.load_module(fullname)
RuntimeError: Python is not installed as a framework. The Mac OS X 
backend will not be able to function correctly if Python is not 
installed as a framework. See the Python documentation for more  
information on installing Python as a framework on Mac OS X. Please 
either reinstall Python as a framework, or try one of the other 
backends. If you are using (Ana)Conda please install python.app and
replace the use of 'python' with 'pythonw'. See 'Working with
 Matplotlib on OSX' in the Matplotlib FAQ for more information.
[2582] Failed to execute script script_V1
logout
Saving session...
...copying shared history...
...saving history...truncating history files...
...completed.

[Process completed]

因此,最終使該方法起作用的方法是強制Matplotlib使用WebAGG並安裝“ tornado”軟件包(出於某些原因而需要)。

暫無
暫無

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

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