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

Environment

# 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 : 3.9.2.final.0
       virtual packages : __win=0=0
                          __archspec=1=x86_64
       base environment : C:Usersrickminiconda3  (writable)
           channel URLs : https://repo.anaconda.com/pkgs/main/win-64
                          https://repo.anaconda.com/pkgs/main/noarch
                          https://repo.anaconda.com/pkgs/r/win-64
                          https://repo.anaconda.com/pkgs/r/noarch
                          https://repo.anaconda.com/pkgs/msys2/win-64
                          https://repo.anaconda.com/pkgs/msys2/noarch
          package cache : C:Usersrickminiconda3pkgs
                          C:Usersrick.condapkgs
                          C:UsersrickAppDataLocalcondacondapkgs
       envs directories : C:Usersrickminiconda3envs
                          C:Usersrick.condaenvs
                          C:UsersrickAppDataLocalcondacondaenvs
               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 ______________________________________________
miniconda3envsxmllibsite-packages_pytestrunner.py:311: in from_call
    result: Optional[TResult] = func()
miniconda3envsxmllibsite-packages_pytestrunner.py:341: in <lambda>
    call = CallInfo.from_call(lambda: list(collector.collect()), "collect")
miniconda3envsxmllibsite-packages_pytestmain.py:690: in collect
    for direntry in visit(str(argpath), self._recurse):
miniconda3envsxmllibsite-packages_pytestpathlib.py:613: in visit
    yield from visit(entry.path, recurse)
miniconda3envsxmllibsite-packages_pytestpathlib.py:613: in visit
    yield from visit(entry.path, recurse)
miniconda3envsxmllibsite-packages_pytestpathlib.py:613: in visit
    yield from visit(entry.path, recurse)
miniconda3envsxmllibsite-packages_pytestpathlib.py:598: 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

LEAVE A COMMENT