I\'m have an issue about displaying the files from a network drive on Windows.
path = "\\\\\\\\nexus\\\\File Server\\\\Technical\\\\MyDrive\\\\Software\\
Just tested on my XP PC, Python 2.7, SMB share \\myshare
os.listdir('\\\\myshare') # Fails with "WindowsError: [Error 53] The network path was not found"
os.listdir('\\\\myshare/folder') # Succeeds
I think some of the confusion could be caused by WindowsError showing the repr()
of the path, rather than the actual path -
>>> repr(path)
"'\\\\myshare'"
>>> str(path)
'\\myshare'
If this is a Python 3 & unicode problem, I suggest trying to fix the string first:
path = "\\\\myshare\folder"
path = bytes(path, "utf-8").decode("unicode_escape")
print os.listdir(path)
(unfortunately I can't test this since I don't have Python 3 installed, but please let me know if it works and I'll edit my answer)
The workaround for this issue is following:
os.listdir('\\networkshares\\folder1\\folder2\\folder3')
It means that you have to use double slashes instead of single one.
This one worked for me:
os.listdir('\\\\server\folder\subfolder\etc')
(with Python 2.7 32b on Win7 64b)