Forum

Author Topic: Error: [Errno 13] Permission denied  (Read 2551 times)

KDSTanhope

  • Newbie
  • *
  • Posts: 10
    • View Profile
Error: [Errno 13] Permission denied
« on: December 17, 2019, 02:47:59 PM »
Hi there.

I am trying to write coordinates to file from within a script.

Code: [Select]
file = open('coord_list.txt', 'w')
raises a permissions error.
I am using the latest version of Metashape. Any work arounds here?

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14846
    • View Profile
Re: Error: [Errno 13] Permission denied
« Reply #1 on: December 17, 2019, 02:51:33 PM »
Hello KDSTanhope,

I suggest to use the absolute path to the existing folder with read/write access permission.

In the example the file will be likely written to the working directory, which may be write-protected.
Best regards,
Alexey Pasumansky,
Agisoft LLC

KDSTanhope

  • Newbie
  • *
  • Posts: 10
    • View Profile
Re: Error: [Errno 13] Permission denied
« Reply #2 on: December 17, 2019, 03:05:19 PM »
I fixed the issue, thanks Alexey.

It was indeed trying to write to the Program Files directory and not the directory where the project was saved.
My solution is to prompt the user to select a path which will then be the default save path:

Code: [Select]
path = Metashape.app.getExistingDirectory("Where to save coords")
and then from within my function:
Code: [Select]
file = open(path+'\coord_list.txt', 'w')