Search code examples
linuxubuntumatplotlibimaging

Ubuntu Linux python plot from emacs, cannot import name '_imaging' from 'PIL'


I just got Ubuntu and I'm trying to experiment abit with emacs. Wrote a simple python code that was supposed to make a plot, but when I try to run the code I get this message; ImportError: cannot import name '_imaging' from 'PIL' (/usr/lib/python3/dist-packages/PIL/init.py) And also I get alot of other random stuff, but I think this is the actual error. I generally want to run the code from the terminal window, and then get out the plot.

Here is the code:

import matplotlib.pyplot as plt
import numpy as np

t = np.arange(0.0,2.0,0.01)
s = 1 + np.sin(2*np.pi*t)
plt.plot(t,s)
plt.show()

Solution

  • I fixed the issue! Just used

    pip install --upgrade --force-reinstall Pillow