OSError: [Error 1] Operation not permitted

前端 未结 4 1165
旧时难觅i
旧时难觅i 2020-12-06 19:29

I am trying to run a python script which uses a binary file (xFiles.bin.addr_patched) created by a postlinker. However, I am getting this error.

File \"abc.p         


        
相关标签:
4条回答
  • 2020-12-06 19:50

    Python code to change the permission:

    from getpwnam import pwd
    from getgrnam import grp
    import os
    
    uid = getpwnam("YOUR_USERNAME")[2]
    gid = grp.getgrnam("YOUR_GROUPNAME")[2]
    os.chown("myPath/xFiles.bin.addr_patched", uid, gid)
    

    Run the script with sudo and you're done.

    0 讨论(0)
  • 2020-12-06 19:51

    My guess is that you should be looking at the permissions for myPath folder instead. Seems like you can't write to it, hence the problem. Try ls -l myPath/.. and see the permissions for myPath. If that's the problem, change the permissions on the folder with chmod.

    P.S. Also, see Google top result on Linux file permissions.

    0 讨论(0)
  • 2020-12-06 19:59

    I had this problem when running a python script on my mac (10.14 Mojave) trying to access /Users/xxx/Pictures/Photos Library.photoslibrary. The full solution can be found in http://osxdaily.com/2018/10/09/fix-operation-not-permitted-terminal-error-macos/

    Summary: Go to System Preferences > Security & Privacy > Privacy > Full Disk Access and add your IDE or python interpreter to the list.

    0 讨论(0)
  • 2020-12-06 20:13

    You could try (from the command line, but I'm sure there's a syntax in python):

    sudo chown your_username:your_groupname filename
    

    Note: The group is usually just your username. I feel like there's something wrong with those permissions though. Read Write Execute for everyone seems to be off. How was this file created? How did it get to be created by the user nobody?

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