permission needed for Python to access USB drive?Can I get “Permission denied” when running out of...

Is it okay for a chapter's POV to shift as it progresses?

how slow a car engine can run

Why is Google approaching my VPS machine?

Sending a photo of my bank account card to the future employer

Wordplay addition paradox

Is it ethical for a company to ask its employees to move furniture on a weekend?

How could a medieval fortress manage large groups of migrants and travelers?

Strategy to pay off revolving debt while building reserve savings fund?

Vienna To Graz By Rail

Operation Unz̖̬̜̺̬a͇͖̯͔͉l̟̭g͕̝̼͇͓̪͍o̬̝͍̹̻

Is straight-up writing someone's opinions telling?

Which GPUs to get for Mathematical Optimization (if any...)?

Was Jacobi the first to notice the ambiguity in the partial derivatives notation? And did anyone object to his fix?

How to honestly answer questions from a girlfriend like "How did you find this place" without giving the impression I'm always talking about my exes?

How would you say "Sorry, that was a mistake on my part"?

How possible is a successful landing just with 1 wing?

Kepler space telescope undetected planets

What were the problems on the Apollo 11 lunar module?

Will this tire fail its MOT?

''Habitable'' planet close to a star

Is this Android phone Android 9.0 or Android 6.0?

What is this green alien supposed to be on the American covers?

Cauchy reals and Dedekind reals satisfy "the same mathematical theorems"

What would be the safest way to drop thousands of small, hard objects from a typical, high wing, GA airplane?



permission needed for Python to access USB drive?


Can I get “Permission denied” when running out of space?How does one make a backup of system-connections on to a USB flash/thumb drive?Exit bash when find gets to a folder with permission deniedwhat does Linux consider connected usb drives and why do they remain as folders when unplugged?Copying to USB drive modifies filenameSudo mkdir fails due to permission denied errorrsync + chmod multiple filesMissing free space on USB drive; xdiskusage shows a “(permission denied)” block: what is it and how to free the space?Allow write access for regular user on CIFS shareHow to use “wc -l ” on this line? Count rows within shell script and output the count value only






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}







0















I got this Python script that reads media files from USB stick. It used to run fine, today it keeps giving me OS Error: [Errno 13] Permission denied: media/myName/usbName when the script runs the command os.listdir().



os.listdir() simply checks what folders and files are in the main folder. It doesn't write anything, so why is there a permission error? I can use the USB stick just fine, open, add and delete files in it myself. I'm not very experienced with Linux, what might be the issue? Some kind of permission, etc. setting for the script file or the usb drive that somehow magically changed without me doing anything?



Using Lubuntu 14.04.










share|improve this question























  • How exactly are you executing the script?

    – steeldriver
    Sep 26 '15 at 0:11











  • python path/to/main.py

    – Leo Ervin
    Sep 26 '15 at 6:26











  • This might give a hint: I installed the same OS on my laptop and ran the exact same script on it, no errors, no permission issues. Also, I just deleted every "folder" in /media/myName, plugged the drive and ran the script again. Ran fine. Why do the folders remain in media/myName after the drive is physically unplugged? Does that give a hint?

    – Leo Ervin
    Sep 26 '15 at 9:06


















0















I got this Python script that reads media files from USB stick. It used to run fine, today it keeps giving me OS Error: [Errno 13] Permission denied: media/myName/usbName when the script runs the command os.listdir().



os.listdir() simply checks what folders and files are in the main folder. It doesn't write anything, so why is there a permission error? I can use the USB stick just fine, open, add and delete files in it myself. I'm not very experienced with Linux, what might be the issue? Some kind of permission, etc. setting for the script file or the usb drive that somehow magically changed without me doing anything?



Using Lubuntu 14.04.










share|improve this question























  • How exactly are you executing the script?

    – steeldriver
    Sep 26 '15 at 0:11











  • python path/to/main.py

    – Leo Ervin
    Sep 26 '15 at 6:26











  • This might give a hint: I installed the same OS on my laptop and ran the exact same script on it, no errors, no permission issues. Also, I just deleted every "folder" in /media/myName, plugged the drive and ran the script again. Ran fine. Why do the folders remain in media/myName after the drive is physically unplugged? Does that give a hint?

    – Leo Ervin
    Sep 26 '15 at 9:06














0












0








0








I got this Python script that reads media files from USB stick. It used to run fine, today it keeps giving me OS Error: [Errno 13] Permission denied: media/myName/usbName when the script runs the command os.listdir().



os.listdir() simply checks what folders and files are in the main folder. It doesn't write anything, so why is there a permission error? I can use the USB stick just fine, open, add and delete files in it myself. I'm not very experienced with Linux, what might be the issue? Some kind of permission, etc. setting for the script file or the usb drive that somehow magically changed without me doing anything?



Using Lubuntu 14.04.










share|improve this question














I got this Python script that reads media files from USB stick. It used to run fine, today it keeps giving me OS Error: [Errno 13] Permission denied: media/myName/usbName when the script runs the command os.listdir().



os.listdir() simply checks what folders and files are in the main folder. It doesn't write anything, so why is there a permission error? I can use the USB stick just fine, open, add and delete files in it myself. I'm not very experienced with Linux, what might be the issue? Some kind of permission, etc. setting for the script file or the usb drive that somehow magically changed without me doing anything?



Using Lubuntu 14.04.







permissions scripting python usb-drive






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Sep 25 '15 at 22:15









Leo ErvinLeo Ervin

1111 bronze badge




1111 bronze badge













  • How exactly are you executing the script?

    – steeldriver
    Sep 26 '15 at 0:11











  • python path/to/main.py

    – Leo Ervin
    Sep 26 '15 at 6:26











  • This might give a hint: I installed the same OS on my laptop and ran the exact same script on it, no errors, no permission issues. Also, I just deleted every "folder" in /media/myName, plugged the drive and ran the script again. Ran fine. Why do the folders remain in media/myName after the drive is physically unplugged? Does that give a hint?

    – Leo Ervin
    Sep 26 '15 at 9:06



















  • How exactly are you executing the script?

    – steeldriver
    Sep 26 '15 at 0:11











  • python path/to/main.py

    – Leo Ervin
    Sep 26 '15 at 6:26











  • This might give a hint: I installed the same OS on my laptop and ran the exact same script on it, no errors, no permission issues. Also, I just deleted every "folder" in /media/myName, plugged the drive and ran the script again. Ran fine. Why do the folders remain in media/myName after the drive is physically unplugged? Does that give a hint?

    – Leo Ervin
    Sep 26 '15 at 9:06

















How exactly are you executing the script?

– steeldriver
Sep 26 '15 at 0:11





How exactly are you executing the script?

– steeldriver
Sep 26 '15 at 0:11













python path/to/main.py

– Leo Ervin
Sep 26 '15 at 6:26





python path/to/main.py

– Leo Ervin
Sep 26 '15 at 6:26













This might give a hint: I installed the same OS on my laptop and ran the exact same script on it, no errors, no permission issues. Also, I just deleted every "folder" in /media/myName, plugged the drive and ran the script again. Ran fine. Why do the folders remain in media/myName after the drive is physically unplugged? Does that give a hint?

– Leo Ervin
Sep 26 '15 at 9:06





This might give a hint: I installed the same OS on my laptop and ran the exact same script on it, no errors, no permission issues. Also, I just deleted every "folder" in /media/myName, plugged the drive and ran the script again. Ran fine. Why do the folders remain in media/myName after the drive is physically unplugged? Does that give a hint?

– Leo Ervin
Sep 26 '15 at 9:06










1 Answer
1






active

oldest

votes


















0














If you want to walk all the subfolders, then try os.walk.
Following example shows how to use it.



import os

for (dirPath, dirNames, fileNames) in os.walk(rootPath):
for fileName in fileNames:
filePath = dirPath + '\' + fileName
print(filePath)
for dirName in dirNames:
path = dirPath + '\' + dirName
print(path)





share|improve this answer








New contributor



나윤재 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






















    Your Answer








    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "106"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f232137%2fpermission-needed-for-python-to-access-usb-drive%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    If you want to walk all the subfolders, then try os.walk.
    Following example shows how to use it.



    import os

    for (dirPath, dirNames, fileNames) in os.walk(rootPath):
    for fileName in fileNames:
    filePath = dirPath + '\' + fileName
    print(filePath)
    for dirName in dirNames:
    path = dirPath + '\' + dirName
    print(path)





    share|improve this answer








    New contributor



    나윤재 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.
























      0














      If you want to walk all the subfolders, then try os.walk.
      Following example shows how to use it.



      import os

      for (dirPath, dirNames, fileNames) in os.walk(rootPath):
      for fileName in fileNames:
      filePath = dirPath + '\' + fileName
      print(filePath)
      for dirName in dirNames:
      path = dirPath + '\' + dirName
      print(path)





      share|improve this answer








      New contributor



      나윤재 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






















        0












        0








        0







        If you want to walk all the subfolders, then try os.walk.
        Following example shows how to use it.



        import os

        for (dirPath, dirNames, fileNames) in os.walk(rootPath):
        for fileName in fileNames:
        filePath = dirPath + '\' + fileName
        print(filePath)
        for dirName in dirNames:
        path = dirPath + '\' + dirName
        print(path)





        share|improve this answer








        New contributor



        나윤재 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.









        If you want to walk all the subfolders, then try os.walk.
        Following example shows how to use it.



        import os

        for (dirPath, dirNames, fileNames) in os.walk(rootPath):
        for fileName in fileNames:
        filePath = dirPath + '\' + fileName
        print(filePath)
        for dirName in dirNames:
        path = dirPath + '\' + dirName
        print(path)






        share|improve this answer








        New contributor



        나윤재 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.








        share|improve this answer



        share|improve this answer






        New contributor



        나윤재 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.








        answered 26 mins ago









        나윤재나윤재

        1




        1




        New contributor



        나윤재 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.




        New contributor




        나윤재 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.
































            draft saved

            draft discarded




















































            Thanks for contributing an answer to Unix & Linux Stack Exchange!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f232137%2fpermission-needed-for-python-to-access-usb-drive%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Taj Mahal Inhaltsverzeichnis Aufbau | Geschichte | 350-Jahr-Feier | Heutige Bedeutung | Siehe auch |...

            Baia Sprie Cuprins Etimologie | Istorie | Demografie | Politică și administrație | Arii naturale...

            Nicolae Petrescu-Găină Cuprins Biografie | Opera | In memoriam | Varia | Controverse, incertitudini...