1

im practicing my python skills so im trying to understand a code. And there is a code like this

   fig.savefig("../figs/SerialDist.png")

But i get an error:

"No such file or directory: '../figs/SerialDist.png'"

And as i already said im pretty new in this, but i think that the problem is that my file path is wrong, so f how can i fix it. Thank you.

Henry Ecker
  • 34,399
  • 18
  • 41
  • 57
neto333
  • 81
  • 6
  • 1
    Do you have the `figs` folder created? If not, consider creating it and testing your code again. – George Aug 02 '21 at 16:56
  • 1
    You could try something like this: https://stackoverflow.com/questions/54401973/pythons-pathlib-get-parents-relative-path – irahorecka Aug 02 '21 at 16:56
  • @George But where should i create that folder? If i write cd it says "C:\Users\MyName". – neto333 Aug 02 '21 at 16:59
  • 1
    `../figs/SerialDist.png` means that the script will try to save your figure in the `figs` folder located one directory up from your current directory. E.g. if you run the following script `C:\MyApp\scripts\script.py` then `../figs/SerialDist.png` is `C:\MyApp\figs\SerialDist.png` – George Aug 02 '21 at 17:03

0 Answers0