I am using the Python 3.8.5 interpreter which is located on WSL2 Ubuntu 20.04. The system itself runs on Windows 10. The problem is that matplotlib does not draw a graph. I use PyCharm as IDE. Tell me please. how can i solve this problem?
import numpy as np
import matplotlib.pyplot as plt
plt.plot(np.array([1,2,3,4,1]))
plt.show()
Unfortunately, this is not yet supported in PyCharm: https://youtrack.jetbrains.com/issue/PY-42827 (and they have no plans yet as to when they're going to fix this).
import matplotlib
matplotlib.use('WebAgg')
import matplotlib.pyplot as plt
This is helpful for me. It will start a web page in where show the picture.
There is also this solution https://medium.com/@shaoyenyu/make-matplotlib-works-correctly-with-x-server-in-wsl2-9d9928b4e36a
Not perfect, but it works
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.