Pycharm: plt.imshow() is not displaying image in sciview Follow
I am a new pycharm professional user. I am trying to visualize the image using matplotib function (plt.imshow()). But, unfortunately, the image is not being displayed. I am unable to resolve this issue even after setting "DISPALY=TRUE" in run configuration settings.
But strangely the following example in Pycharm Doc "https://www.jetbrains.com/help/pycharm/matplotlib-tutorial.html" works perfectly fine and displays image. Also the scientific mode is enabled always.
Please, kindly help me to resolve this.
Please sign in to leave a comment.
Thank you for contacting PyCharm support.
Are you able to view Data for some other variables in your code (the field where you currently type 'image')?
Looking forward to your reply.
Sorry, I haven't noticed that you have a console opened.
PyCharm is currently trying to take it from Console, instead of Debugger.
Please close the console and try again, it should work.
Thank you for the update.
Have you tried to stop the debugger and run it again? I cannot see the the field for data and Format, which is quite strange.
Please try the following:
1) Stop the debugger and close all the tabs and SciView window.
2) Remove the breakpoints.
3) File | Invalidate Cashes / Restart...
4) Wait for the indexing completion and run your code with Ctrl+Shift+F10 (⌃⇧R for Mac OS).
5) Set the breakpoint and run a debugger.
Please let me know the result.
The Drive to Develop
i have a similar / the same problem. I am not quite sure.
Intellij shows the message when i try to display a plot with plt.show()
[..] python3.6/site-packages/matplotlib/figure.py:445: UserWarning: Matplotlib is currently using agg, which is a non-GUI backend, so cannot show the figure.
When i try so use another backend the plt.show() function than either throws a long stack, which end displays:
"AttributeError: 'NoneType' object has no attribute 'session'",
or opens a figure, but does not really show anything.
When i run the code as a Program and with the GTK3Cairo backend, the picture actually opens. This backend however does not work in the console.
However i like working with the python3 console, any advice?
Please try running your script from the system terminal (outside of PyCharm) using the same interpreter. What's the result?
Please make sure to you exactly the same interpreter as in PyCharm, it is important.
Same output, same result.
Btw. i am using the IntelliJ Ultimate Edition...
Having the same result outside of PyCharm means that the problem is actually not related to PyCharm. You should locate the problem in your system. Try googling your error output.
Pengfeidip answer worked for me
Ockham's Razor principle, thanks @Pengfeidip !
fixed this issue on MacOSX
Pengfeidip Thanks for sharing.
Thanks, Tiottt for confirming that Peng's solution worked