question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unable to use pytest from mapped network drive

See original GitHub issue
  • a detailed description of the bug or suggestion Running pyest --version using PowerShell displays the pytest version when I’m in my home directory or any other local directory on my Windows machine. When I cd into a mapped network drive (Q:\) and run pyest --version, I get PermissionError: [WinError 5] Access is denied: '.'. I get the same error when I run pyest --version inside as well as outside a virtual environment when I’m in a mapped network drive.
  • output of pip list from the virtual environment you are using
(env) PS Q:\Projects\Abhilash\Feeds> pip list
Package            Version
------------------ -------
asn1crypto         0.24.0
astroid            2.2.5
atomicwrites       1.3.0
attrs              19.1.0
bcrypt             3.1.7
cffi               1.12.3
colorama           0.4.1
coverage           4.5.4
cryptography       2.7
importlib-metadata 0.20
isort              4.3.21
lazy-object-proxy  1.4.2
mccabe             0.6.1
more-itertools     7.2.0
packaging          19.1
paramiko           2.6.0
pip                19.0.3
pluggy             0.12.0
py                 1.8.0
pycparser          2.19
pylint             2.3.1
pymssql            2.1.4
PyNaCl             1.3.0
pyparsing          2.4.2
pytest             5.1.2
pytest-cov         2.7.1
setuptools         40.8.0
six                1.12.0
typed-ast          1.4.0
wcwidth            0.1.7
wrapt              1.11.2
zipp               0.6.0
You are using pip version 19.0.3, however version 19.2.3 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip'
command.
  • pytest and operating system versions
PS C:\Users\kishorea> pytest --version
This is pytest version 5.1.2, imported from c:\users\kishorea\appdata\local\programs\python\python37\lib\site-packages\pytest.py
setuptools registered plugins:
  pytest-cov-2.7.1 at c:\users\kishorea\appdata\local\programs\python\python37\lib\site-packages\pytest_cov\plugin.py
PS C:\Users\kishorea>
PS C:\Users\kishorea> (Get-WMIObject win32_operatingsystem).name
Microsoft Windows 10 Enterprise|C:\WINDOWS|\Device\Harddisk0\Partition4
  • minimal example if possible
PS C:\Users\kishorea> pytest --version
This is pytest version 5.1.2, imported from c:\users\kishorea\appdata\local\programs\python\python37\lib\site-packages\pytest.py
setuptools registered plugins:
  pytest-cov-2.7.1 at c:\users\kishorea\appdata\local\programs\python\python37\lib\site-packages\pytest_cov\plugin.py
PS C:\Users\kishorea> q:
PS Q:\> pytest --version
Traceback (most recent call last):
  File "c:\users\kishorea\appdata\local\programs\python\python37\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "c:\users\kishorea\appdata\local\programs\python\python37\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Users\kishorea\AppData\Local\Programs\Python\Python37\Scripts\pytest.exe\__main__.py", line 9, in <module>
  File "c:\users\kishorea\appdata\local\programs\python\python37\lib\site-packages\_pytest\config\__init__.py", line 59, in main
    config = _prepareconfig(args, plugins)
  File "c:\users\kishorea\appdata\local\programs\python\python37\lib\site-packages\_pytest\config\__init__.py", line 195, in _prepareconfig
    config = get_config(args, plugins)
  File "c:\users\kishorea\appdata\local\programs\python\python37\lib\site-packages\_pytest\config\__init__.py", line 160, in get_config
    args=args, plugins=plugins, dir=Path().resolve()
  File "c:\users\kishorea\appdata\local\programs\python\python37\lib\pathlib.py", line 1151, in resolve
    s = self._flavour.resolve(self, strict=strict)
  File "c:\users\kishorea\appdata\local\programs\python\python37\lib\pathlib.py", line 202, in resolve
    s = self._ext_to_normal(_getfinalpathname(s))
PermissionError: [WinError 5] Access is denied: '.'
PS Q:\>

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:11 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
nicoddemuscommented, Jul 27, 2020

This will be fixed in pytest 6.0 because we are no longer resolving paths. 👍

0reactions
manum45commented, Jul 23, 2020

A similar issue occurs on RAM disks (O:\ in this case):

O:\>C:\ProgramData\Anaconda3\python.exe -m pytest --version
Traceback (most recent call last):
  File "C:\ProgramData\Anaconda3\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "C:\ProgramData\Anaconda3\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\ProgramData\Anaconda3\lib\site-packages\pytest.py", line 101, in <module>
    raise SystemExit(pytest.main())
  File "C:\ProgramData\Anaconda3\lib\site-packages\_pytest\config\__init__.py", line 71, in main
    config = _prepareconfig(args, plugins)
  File "C:\ProgramData\Anaconda3\lib\site-packages\_pytest\config\__init__.py", line 207, in _prepareconfig
    config = get_config(args, plugins)
  File "C:\ProgramData\Anaconda3\lib\site-packages\_pytest\config\__init__.py", line 172, in get_config
    args=args, plugins=plugins, dir=Path().resolve()
  File "C:\ProgramData\Anaconda3\lib\pathlib.py", line 1151, in resolve
    s = self._flavour.resolve(self, strict=strict)
  File "C:\ProgramData\Anaconda3\lib\pathlib.py", line 202, in resolve
    s = self._ext_to_normal(_getfinalpathname(s))
OSError: [WinError 1] Incorrect function: '.'

This behavior seems to be described here: https://bugs.python.org/issue31842

Edit: Error occurs with:

Python 3.7.4 (default, Aug  9 2019, 18:34:13) [MSC v.1915 64 bit (AMD64)] :: Anaconda, Inc. on win32

pytest                             5.2.1
pytest-arraydiff                   0.3
pytest-astropy                     0.5.0
pytest-doctestplus                 0.4.0
pytest-openfiles                   0.4.0
pytest-remotedata                  0.3.2
python-dateutil                    2.8.0
Read more comments on GitHub >

github_iconTop Results From Across the Web

Retrieving contents from a directory on a network drive ...
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...
Read more >
os.path.realpath on Windows resolves mapped network drives
relpath() fails if the target and start directories aren't on the same drive. Code that's creating a symlink in Windows has to handle...
Read more >
Solved: Why is the Python script not able to read network
Solved: Hi All, I have written a python script which merely reads the file from the network drive. When I am running this...
Read more >
access is denied error 5 for network drive mapping ?
I working on script running on sql server 2019 using python 3.10 . I have directory path \\192.168.7.9\Import\8 as mapped network drive and ......
Read more >
running python script in visual code - network drives are not ...
on Windows 10, I have mapped network drives to several drive letters (M:\\ and G:\\ specifically), but for some reason, I can`t access...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found