Python Matplotlib errors with savefig (newbie).

后端 未结 3 526
小蘑菇
小蘑菇 2021-01-28 18:15

All parts of Python on my computer were recently installed from the Enthought academic package, but use Pyscripter for editing and running code. I\'m very early in my learning

相关标签:
3条回答
  • 2021-01-28 18:28

    If it helps others, I made the silly mistake of not actually designating a file name and as a result had returned the same error message that lead me to this question for review.

    Here is the code that was generating the error:

    plt.savefig('C:\\Users\\bwarn\\Canopy', format='png')
    

    Here is my correction that resolved (you'll see I designated the actual file and name)

    plt.savefig('C:\\Users\\bwarn\\Canopy\\myplot.png', format='png')
    
    0 讨论(0)
  • 2021-01-28 18:29

    There's nothing wrong with your code. I just tested it locally on my machine. The issue is this error:

    IOError: [Errno 13] Permission denied: 'TestHist.png'
    

    You are most likely trying to save the file somewhere that the Python process doesn't have permission to access. What OS are you on? Where are you trying to save the file?

    0 讨论(0)
  • 2021-01-28 18:29

    The following worked for me when I was running a neural network on my windows machine:

     image_path = 'A:/DeepLearning/Padhai/MLFlow/images/%s.png' % (expt_id)
            plt.savefig(image_path)
    

    Or otherwise refer:

    Using 'r' in front of the path

    0 讨论(0)
提交回复
热议问题