Reputation: 1777
I am attempting to use matplotlib
on a Python script in Azure, using a WebJob on a Web App. I am getting the error below:
The error is obviously when importing tkinter
, but based on this, it appears tkinter
is not available in Azure. This is not a problem for me, as when I use it, I am just creating a PNG, so I believe I don't actually need it.
How can I get around this problem?
Upvotes: 1
Views: 2122
Reputation: 66
I solved this problem through this.
import matplotlib
matplotlib.use('agg')
import matplotlib.pyplot as plt
Upvotes: 4
Reputation: 24128
According to the logs of your WebJob, you are using Azure WebApp for Windows to run it. Unfortunately, due to the Win32k.sys (User32/GDI32) Restrictions
of Azure Web App sandbox
, the job to create a PNG by matplotlib
will never work for you, even after fix the current issue, because matplotlib
requires GDI
.
So I suggest that you can try to make the same Python script works on Linux and use crontab
to trigger it, and to write a Dockerfile or build an Docker image for deployment on Azure WebApp for Linux. Please refer to the offical document Create a Python app in Azure App Service on Linux
to get start.
Upvotes: 0
Reputation: 268
You can't install tkinter with sudo apt-get install python-tk
?
I usually have to install the package this way before it will work.
Upvotes: 0