Import matplotlib does not work on Heroku

[(Basically this is identical to this a few months ago: import matplotlib failing without a module named _tkinter on heroku , however, the only solution does not seem to work. (Unfortunately, I can not comment on the answer provided there, because I do not have enough StackOverflow reputation .))]

I am using matplotlib in my application. Everything is working fine. However, when I click on my app on Heroku, I get an error message:

import _tkinter # If this fails your Python may not be configured for Tk
ImportError: No module named _tkinter

I tried to get around Tkinter by doing:

import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt, mpld3

However, this still causes the same error.

Has anyone found a solution for this or has a Heroku application with matplotlib that works? I am running Python 2.7.13 (this is also the version of Heroku installed when I click on the application).

+6
2

Heroku :

" Heroku Python libs, tkinter. , : https://devcenter.heroku.com/articles/cedar-ubuntu-packages

buildpacks https://devcenter.heroku.com/articles/third-party-buildpacks, https://elements.heroku.com/buildpacks .

, - , . . , , . SO, Python buildpacks fooobar.com/questions/1016887/...

Apt buildpack : https://github.com/heroku/heroku-buildpack-apt

heroku buildpacks:add --index 1 https://github.com/heroku/heroku-buildpack-apt

Aptfile :

python3-tk

, Aptfile , .

buildpack: https://github.com/thenovices/heroku-buildpack-scipy. matplotlib.

+2

:

matplotlib tkinter - . :

import matplotlib
matplotlib.use('Agg')

, , ( "Agg", "SVG" .. ..)

matplotlibrc : https://matplotlib.org/users/customizing.html#the-matplotlibrc-file

+1

Source: https://habr.com/ru/post/1016884/


All Articles