os.mkdir(path) returns OSError when directory does not exist

后端 未结 10 2197
挽巷
挽巷 2020-12-08 09:54

I am calling os.mkdir to create a folder with a certain set of generated data. However, even though the path I specified has not been created, the os.mkdi

10条回答
  •  执念已碎
    2020-12-08 10:29

    Happened to me on Windows, maybe this is the case:

    Like you I was trying to :

    os.mkdir(dirname)
    

    and got OSError: [Errno 17] File exists: ''. When I ran:

    os.path.exists(dirname)
    

    I got false, and it drove me mad for a while :)

    The problem was: In a certain window I was at the specific directory. Even though it did not exists at that time (I removed it from linux). The solution was to close that window \ navigate to somewhere else. Shameful, I know ...

提交回复
热议问题