enable Windows user to create symbolic links

Windows users may not have permission to create a symbolic link by default. Symptoms from Python result:

from pathlib import Path

Path('x').touch()
Path('x').symlink_to('y')

or

import os

os.symlink('x', 'y')

OSError: symbolic link privilege not held

Fix: put Windows into Developer Mode: Settings → Updates & Security → For Developers → Use developer features: Select “Developer mode”

Restart computer, and once again try Python script above to see that Python can create symbolic links.

If it’s still not possible to create symbolic links, you may simply need to use Python ≥ 3.8.

Group Policy: press Windows + R key (run dialog) and type

gpedit.msc

If gpedit.msc is not available, use Python ≥ 3.8 with Windows in Developer Mode as above.


Navigate to create user permission to create symbolic links:

Computer Configuration → Windows Settings → Security Settings → Local Policies → User Rights Assignment → Create symbolic links

type the user name and click “Check Names” then OK.

Reboot the computer (or logoff, logon) to make the permissions take effect.

Reference: Python os.symlink() on Windows generally requires Python ≥ 3.8

Related: symbolic links on Windows