مشكلة في التثبيت مع matplotlib Python
macos anaconda (1)
هذا السؤال لديه بالفعل إجابة هنا:
- إطار python matplotlib تحت macosx؟ 8 إجابات
لدي مشكلة بعد تثبيت حزمة matplotlib غير قادرة على استيراد matplotlib.pyplot كـ plt . أي اقتراح سيكون موضع تقدير كبير.
>>> import matplotlib.pyplot as plt
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "//anaconda/lib/python2.7/site-packages/matplotlib-1.3.1-py2.7-macosx-10.5-x86_64.egg/matplotlib/pyplot.py", line 98, in <module>
_backend_mod, new_figure_manager, draw_if_interactive, _show = pylab_setup()
File "//anaconda/lib/python2.7/site-packages/matplotlib-1.3.1-py2.7-macosx-10.5-x86_64.egg/matplotlib/backends/__init__.py", line 28, in pylab_setup
globals(),locals(),[backend_name],0)
File "//anaconda/lib/python2.7/site-packages/matplotlib-1.3.1-py2.7-macosx-10.5-x86_64.egg/matplotlib/backends/backend_macosx.py", line 21, in <module>
from matplotlib.backends import _macosx
**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.
سبب المشكلة في صورة ماكنتوش تقديم النهاية مرة أخرى من matplotlib (ما هو بين الخلفية لجعل باستخدام API من الكاكاو افتراضيا). هناك Qt4Agg و GTKAgg وكطرف الخلفي ليس الافتراضي. تعيين النهاية الخلفية macosx التي تختلف مقارنة مع النوافذ الأخرى أو نظام التشغيل لينكس.
أنا حل هذه المشكلة باتباع الطرق التالية:
- أفترض أنك قمت بتثبيت pip matototlib ، هناك دليل في
~/.matplotlib
يسمى~/.matplotlib
. - إنشاء ملف
~/.matplotlib/matplotlibrc
هناك وإضافة التعليمة البرمجية التالية:backend: TkAgg
من هذا link يمكنك محاولة رسم تخطيطي مختلف.