我有這樣的進口和代碼:導入錯誤:沒有模塊名爲backend_tkagg
import pandas as pd
import numpy as np
import statsmodels.formula.api as sm
import matplotlib.pyplot as plt
#Read the data from pydatasets repo using Pandas
url = './file.csv'
white_side = pd.read_csv(url)
#Fitting the model
model = sm.ols(formula='budget ~ article_size',
data=white_side,
subset=white_side['producer'] == "Peter Jackson")
fitted = model.fit()
print fitted.summary()
這段代碼執行後我有這樣的錯誤:
/usr/bin/python2.7 /home/seth/PycharmProjects/osiris_project/PMN_way/start.py
Traceback (most recent call last):
File "/home/seth/PycharmProjects/osiris_project/PMN_way/start.py", line 5, in <module>
import matplotlib.pyplot as plt
File "/usr/lib64/python2.7/site-packages/matplotlib/pyplot.py", line 98, in <module>
_backend_mod, new_figure_manager, draw_if_interactive, _show = pylab_setup()
File "/usr/lib64/python2.7/site-packages/matplotlib/backends/__init__.py", line 25, in pylab_setup
globals(),locals(),[backend_name])
ImportError: No module named backend_tkagg
Process finished with exit code 1
我真的使用的openSUSE和pycharm社區版最新版本與安裝的熊貓,numpy等 我該如何解決這個問題?
很好的回答。官方的matplotlib配置示例:http://matplotlib.org/users/customizing.html – Plamen
這不適合我。但是,我可以通過在導入matplotlib.pyplot之前導入後端模塊來修復錯誤。看到我的答案。我期望有比我更好的解決方案,包括指定後端模塊的路徑。 – user3731622