PermissionError: [WinError 5] Access is denied pytest after conda install

  anaconda, pytest, windows

PermissionError: [WinError 5] Access is denied – running pytest after fresh conda install


# packages in environment at C:Usersrickminiconda3envsxml:
# Name                    Version                   Build  Channel
pytest                    6.2.2            py39haa95532_2
(xml) c:Usersrick>conda info

     active environment : xml
    active env location : C:Usersrickminiconda3envsxml
            shell level : 2
       user config file : C:Usersrick.condarc
 populated config files : C:Usersrick.condarc
          conda version : 4.9.2
    conda-build version : not installed
         python version :
       virtual packages : __win=0=0
       base environment : C:Usersrickminiconda3  (writable)
           channel URLs :
          package cache : C:Usersrickminiconda3pkgs
       envs directories : C:Usersrickminiconda3envs
               platform : win-64
             user-agent : conda/4.9.2 requests/2.25.1 CPython/3.9.2 Windows/10 Windows/10.0.18362
          administrator : False
             netrc file : None
           offline mode : False
(xml) c:Usersrick>pytest
=================================================== test session starts ===================================================
platform win32 -- Python 3.9.2, pytest-6.2.2, py-1.9.0, pluggy-0.13.1
rootdir: c:Usersrick
collected 0 items / 1 error

========================================================= ERRORS ==========================================================
______________________________________________ ERROR collecting test session ______________________________________________ in from_call
    result: Optional[TResult] = func() in <lambda>
    call = CallInfo.from_call(lambda: list(collector.collect()), "collect") in collect
    for direntry in visit(str(argpath), self._recurse): in visit
    yield from visit(entry.path, recurse) in visit
    yield from visit(entry.path, recurse) in visit
    yield from visit(entry.path, recurse) in visit
    for entry in os.scandir(path):
E   PermissionError: [WinError 5] Access is denied: 'c:UsersrickAppDataLocalApplication Data'
================================================= short test summary info =================================================
ERROR  - PermissionError: [WinError 5] Access is denied: 'c:UsersrickAppDataLocalApplication Data'
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
==================================================== 1 error in 2.35s =====================================================

From a Microsoft Technet post

The Application Data folder in that location is not a normal folder. It is a folder Junction and is normally hidden, by default. The only reason that the junction exists is to redirect legacy applications, that are hard coded to look for that folder, to the new location in Windows 7.

Seems odd that pytest would point to a deprecated "folder junction"? How to resolve?

Source: Windows Questions