4

I run

import matplotlib.pyplot as plt
plt.plot(range(0, 10, 1)) #or "plt.plot(range(10))"
plt.show()

and it does nothing (except saying "Process finished with exit code 0" ). I am using PyCharm, on Windows 7, I installed matplotlib via PyCharm's package manager. I installed python 2.7 and PyCharm today (I practiced it for a month at codecadamy.com but I wanted to get accustomed to real conditions), so I am noob, and it can happen that the problem is trivial.

I tried various codes at matplotlib.org with no results.

Luka Petrović
  • 329
  • 3
  • 9
  • `Process finished with exit code 0` means that it executed without an error. It's strange that a pop-up window doesn't appear. Try saving the figure using `plt.savefig` and checking if it did. Additionally `show` was intended to be used as a script more than as an interactive plot. Are you running that as a script or from some IDE/IDLE/REPL (write a command press enter...)? Try using `plt.ion()` and then repeating the commands to see if a plot appears. Disclaimer though, I don't use PyCharm. – ljetibo May 07 '15 at 17:34
  • I am running it as a script. I tried `plt.ion()`, nothing happens. I tried `plt.savefig("image.png")` it did not save it (i checked in the folder where the whole project is). – Luka Petrović May 07 '15 at 17:52
  • are you sure it saved it there? Can you write `import os` at the top and then `print(os.path.abspath(os.path.curdir)` right before you do the `plt.savefig`. The path it prints out is the one where the image is saved. If that doesn't work the best I can do for you is direct you to [PyCharm help forums](http://forum.jetbrains.com/forum/PyCharm) – ljetibo May 07 '15 at 18:13
  • I just run the wrong script, i did not expect that it would run old script if this one is opened. – Luka Petrović May 07 '15 at 18:17

2 Answers2

1

Ok, apparently i made the stupidest mistake ever. I had multiple tabs opened, and I constantly run the first one, instead of the one i should have. Should I delete question? I'm so embarrassed.

Luka Petrović
  • 329
  • 3
  • 9
  • 1
    don't delete it, just mark your own answer correct and let it go. I think there's a time period of 48h before you can do that but I'm not sure. – ljetibo May 07 '15 at 18:32
  • 1
    Please delete it. I voted to close. Keeping this question around won't help anyone. It will only waste people's time who are having a real problem that happens to hit on the same key words. – Eryk Sun May 07 '15 at 18:38
0

You can try uninstalling python, and reinstalling again.

Or check out this link, it's similar to your question: matplotlib plot window won't appear

Community
  • 1
  • 1
l-spark
  • 871
  • 2
  • 10
  • 25