Os.makedirs() / Os.mkdir() On Windows. No Error, But No (visible) Folder Created
Solution 1:
I just had the same thing happen to me, except I was creating a folder in the AppData/Roaming directory and was using the version of Python from the Microsoft Store.
Apparently, files and directories created in AppData using that version of Python, will instead be created in:
%LocalAppData%\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache
Solution 2:
I found what causes this problem finally!
All of the created test folders have been moved to a folder named VTROOT. This folder is created by Comodo Internet Security I use...Its "Auto-Containment" moved all folders I set up by running the code from .py-file (only then) in the PowerShell.
Disabling the auto-containment of Comodo solves the problem..Oh my..
Thank you anyways!
Solution 3:
the "if
" part will check if the file exists already and consequentially solve the ERROR: '[WinError 183] Cannot create a file when that file already exists:'
the "import sys
" part will fix the issue with windows where the folder is created but not visible by the user (even with show hidden files turned on)
import sys
import ospath = 'your path'
def make_dir():
ifnotos.path.exists(Path):
os.makedirs(Path)
or
import sys
import os
path = 'your path'defmake_dir():
mode = 0o666#read and write for all users and groups # form more permission codes search for: *chmod number codes*ifnot os.path.exists(Path):
os.mkdir(Path, mode)
Solution 4:
Try adding the below import statement:
import sys
This should work.
Post a Comment for "Os.makedirs() / Os.mkdir() On Windows. No Error, But No (visible) Folder Created"