Python cannot access a Windows shared drive, even though other applications can

2.9k Views Asked by At

I have three computers with seemingly identical Windows (all installed by IT-department based on same image) and WinPython installations. One of the computers cannot access a shared drive through Python, while the others can.

The shared drive can be accessed through Windows and through other applications, but Spyder (a Python application) and command-line python cannot. We have tried using:

>>> import os
>>> os.access('v:', os.W_OK) # v: is the shared folder
False

Furthermore, we have tried using the UNC path:

>>> os.access(r'\\server_name\\folder', os.W_OK)
False

Both these commands return True on the other computers.

We suspect that this has something to do with the permissions of the shared folder for specific programs, e.g. python, but when comparing the Properties->Security tab across computers, we see no difference in the permissions there.

Does anyone have any further ideas what to try or how to investigate further if this may be a permissions problem?

1

There are 1 best solutions below

1
On

You need the \ on the path, not just the drive letter. If you tried os.access('v:\\', os.W_OK) instead of the v: without the slash I bet it would work.