Pycharm doesn't show image(matplotlib)

丶灬走出姿态 提交于 2021-02-05 12:29:03

问题


This code, doesn't show image:

plt.imshow(Image.open(img_paths[0]))

Maybe i need a pro version?


回答1:


The following code works in PyCharm. The image is displayed in a new window. I copied my image named image.png into my PyCharm project's venv folder so that PyCharm would find it automatically. Instead of pasting an image named image.png into your PyCharm project's venv folder, you could do the same with your list named img_paths.

import matplotlib.pyplot as plt
from PIL import Image

fname = 'image.png'
plt.imshow(Image.open(fname))
plt.show()

Note: PyCharm does not automatically find your globally installed Python packages unless the project has been configured to find them. To do this select the Inherit global-site packages option when you create a new project.

Select File -> New Project to create a new project. Click the triangle marked by the mouse cursor in the below screenshot to show the new project's options.

Then check the Inherit global-site packages checkbox and click the Create button in the lower right corner of the Create Project window.



来源:https://stackoverflow.com/questions/59367642/pycharm-doesnt-show-imagematplotlib

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!