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.

Pipenv install failes because Access Denied to npm

See original GitHub issue

Issue description

When I run pipenv install in any directory, I get PermissionError: [WinError 5] Access is denied: 'C:\\WINDOWS\\system32\\config\\systemprofile\\AppData\\Roaming\\npm

Debugging already attempted

I already read this issue and tried --sequential, but it still didn’t work.

I’ve uninstalled and reinstalled Pipenv, Pyenv, and Node.js. I tried using a different Python/Pip install to get Pipenv. I’ve also tried moving Python and related things to the top of my PATH to avoid every looking at NPM. The error message has remained the same.

My next step will be to fully delete everything related to Python and try from scratch, but before I go that far, I thought I’d see if anyone has expert guidance here. Especially, why Pathlib would be looking at npm AppData at all.

I checked the file system, and 'C:\WINDOWS\system32\config\` exists, but it is an empty folder.

Expected result

I expect the install to complete.

Actual result

Traceback (most recent call last):
  File "c:\users\USER\.pyenv\pyenv-win\versions\3.9.6\lib\runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "c:\users\USER\.pyenv\pyenv-win\versions\3.9.6\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "C:\Users\USER\.pyenv\pyenv-win\versions\3.9.6\Scripts\pipenv.exe\__main__.py", line 7, in <module>      
  File "c:\users\USER\.pyenv\pyenv-win\versions\3.9.6\lib\site-packages\pipenv\vendor\click\core.py", line 1128, in __call__
    return self.main(*args, **kwargs)
  File "c:\users\USER\.pyenv\pyenv-win\versions\3.9.6\lib\site-packages\pipenv\cli\options.py", line 54, in main

    return super().main(*args, **kwargs, windows_expand_args=False)
  File "c:\users\USER\.pyenv\pyenv-win\versions\3.9.6\lib\site-packages\pipenv\vendor\click\core.py", line 1053, in main
    rv = self.invoke(ctx)
  File "c:\users\USER\.pyenv\pyenv-win\versions\3.9.6\lib\site-packages\pipenv\vendor\click\core.py", line 1659, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "c:\users\USER\.pyenv\pyenv-win\versions\3.9.6\lib\site-packages\pipenv\vendor\click\core.py", line 1395, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "c:\users\USER\.pyenv\pyenv-win\versions\3.9.6\lib\site-packages\pipenv\vendor\click\core.py", line 754, 
in invoke
    return __callback(*args, **kwargs)
  File "c:\users\USER\.pyenv\pyenv-win\versions\3.9.6\lib\site-packages\pipenv\vendor\click\decorators.py", line 84, in new_func
    return ctx.invoke(f, obj, *args, **kwargs)
  File "c:\users\USER\.pyenv\pyenv-win\versions\3.9.6\lib\site-packages\pipenv\vendor\click\core.py", line 754, 
in invoke
    return __callback(*args, **kwargs)
  File "c:\users\USER\.pyenv\pyenv-win\versions\3.9.6\lib\site-packages\pipenv\cli\command.py", line 193, in install
    do_install(
  File "c:\users\USER\.pyenv\pyenv-win\versions\3.9.6\lib\site-packages\pipenv\core.py", line 1852, in do_install
    ensure_project(
  File "c:\users\USER\.pyenv\pyenv-win\versions\3.9.6\lib\site-packages\pipenv\core.py", line 512, in ensure_project
    ensure_virtualenv(
  File "c:\users\USER\.pyenv\pyenv-win\versions\3.9.6\lib\site-packages\pipenv\core.py", line 436, in ensure_virtualenv
    python = ensure_python(project, three=three, python=python)
  File "c:\users\USER\.pyenv\pyenv-win\versions\3.9.6\lib\site-packages\pipenv\core.py", line 328, in ensure_python
    path_to_python = find_a_system_python(python)
  File "c:\users\USER\.pyenv\pyenv-win\versions\3.9.6\lib\site-packages\pipenv\core.py", line 293, in find_a_system_python
    return next(iter(finder.find_all_python_versions()), None)
  File "c:\users\USER\.pyenv\pyenv-win\versions\3.9.6\lib\site-packages\pipenv\vendor\pythonfinder\pythonfinder.py", line 312, in find_all_python_versions
    python_version_dict = getattr(self.system_path, "python_version_dict", {})
  File "c:\users\USER\.pyenv\pyenv-win\versions\3.9.6\lib\site-packages\pipenv\vendor\pythonfinder\pythonfinder.py", line 120, in system_path
    self._system_path = self.create_system_path()
  File "c:\users\USER\.pyenv\pyenv-win\versions\3.9.6\lib\site-packages\pipenv\vendor\pythonfinder\pythonfinder.py", line 82, in create_system_path
    return pyfinder_path.SystemPath.create(
  File "C:\Users\USER\.pyenv\pyenv-win\versions\3.9.6\Lib\site-packages\pipenv\vendor\pythonfinder\models\path.py", line 694, in create
    instance = instance._run_setup()
  File "C:\Users\USER\.pyenv\pyenv-win\versions\3.9.6\Lib\site-packages\pipenv\vendor\pythonfinder\models\path.py", line 241, in _run_setup
    path_order=[p.as_posix() for p in path_instances if p.exists()],
  File "C:\Users\USER\.pyenv\pyenv-win\versions\3.9.6\Lib\site-packages\pipenv\vendor\pythonfinder\models\path.py", line 241, in <listcomp>
    path_order=[p.as_posix() for p in path_instances if p.exists()],
  File "c:\users\USER\.pyenv\pyenv-win\versions\3.9.6\lib\pathlib.py", line 1414, in exists
    self.stat()
  File "c:\users\USER\.pyenv\pyenv-win\versions\3.9.6\lib\pathlib.py", line 1222, in stat
    return self._accessor.stat(self)
PermissionError: [WinError 5] Access is denied: 'C:\\WINDOWS\\system32\\config\\systemprofile\\AppData\\Roaming\\npm'

Steps to replicate

I do not think this is a precise way to replicate, but the related actions I’ve made (that I can think of) are: Install pipenv via a Conda-based Python Install pyenv-win using the steps given in the docs Install Node.js Try to run pipenv install

Please run $ pipenv --support, and paste the results here. Don’t put backticks (`) around it! The output already contains Markdown formatting. ‘’’ Traceback (most recent call last): File “c:\users\USER.pyenv\pyenv-win\versions\3.9.6\lib\runpy.py”, line 197, in _run_module_as_main return _run_code(code, main_globals, None, File “c:\users\USER.pyenv\pyenv-win\versions\3.9.6\lib\runpy.py”, line 87, in run_code exec(code, run_globals) File "C:\Users\USER.pyenv\pyenv-win\versions\3.9.6\Scripts\pipenv.exe_main.py", line 7, in <module>
File “c:\users\USER.pyenv\pyenv-win\versions\3.9.6\lib\site-packages\pipenv\vendor\click\core.py”, line 1128, in call return self.main(*args, **kwargs) File “c:\users\USER.pyenv\pyenv-win\versions\3.9.6\lib\site-packages\pipenv\cli\options.py”, line 54, in main return super().main(*args, **kwargs, windows_expand_args=False) File “c:\users\USER.pyenv\pyenv-win\versions\3.9.6\lib\site-packages\pipenv\vendor\click\core.py”, line 1053, in main rv = self.invoke(ctx) File “c:\users\USER.pyenv\pyenv-win\versions\3.9.6\lib\site-packages\pipenv\vendor\click\core.py”, line 1637, in invoke super().invoke(ctx) File “c:\users\USER.pyenv\pyenv-win\versions\3.9.6\lib\site-packages\pipenv\vendor\click\core.py”, line 1395, in invoke return ctx.invoke(self.callback, **ctx.params) File “c:\users\USER.pyenv\pyenv-win\versions\3.9.6\lib\site-packages\pipenv\vendor\click\core.py”, line 754, in invoke return __callback(*args, **kwargs) File “c:\users\USER.pyenv\pyenv-win\versions\3.9.6\lib\site-packages\pipenv\vendor\click\decorators.py”, line 84, in new_func return ctx.invoke(f, obj, *args, **kwargs) File “c:\users\USER.pyenv\pyenv-win\versions\3.9.6\lib\site-packages\pipenv\vendor\click\core.py”, line 754, in invoke return __callback(*args, **kwargs) File “c:\users\USER.pyenv\pyenv-win\versions\3.9.6\lib\site-packages\pipenv\vendor\click\decorators.py”, line 26, in new_func return f(get_current_context(), *args, **kwargs) File “c:\users\USER.pyenv\pyenv-win\versions\3.9.6\lib\site-packages\pipenv\cli\command.py”, line 103, in cli get_pipenv_diagnostics(state.project) File “c:\users\USER.pyenv\pyenv-win\versions\3.9.6\lib\site-packages\pipenv\help.py”, line 31, in get_pipenv_diagnostics python_paths = finder.find_all_python_versions() File “c:\users\USER.pyenv\pyenv-win\versions\3.9.6\lib\site-packages\pipenv\vendor\pythonfinder\pythonfinder.py”, line 312, in find_all_python_versions python_version_dict = getattr(self.system_path, “python_version_dict”, {}) File “c:\users\USER.pyenv\pyenv-win\versions\3.9.6\lib\site-packages\pipenv\vendor\pythonfinder\pythonfinder.py”, line 120, in system_path self._system_path = self.create_system_path() File “c:\users\USER.pyenv\pyenv-win\versions\3.9.6\lib\site-packages\pipenv\vendor\pythonfinder\pythonfinder.py”, line 82, in create_system_path return pyfinder_path.SystemPath.create( File “C:\Users\USER.pyenv\pyenv-win\versions\3.9.6\Lib\site-packages\pipenv\vendor\pythonfinder\models\path.py”, line 694, in create instance = instance._run_setup() File “C:\Users\USER.pyenv\pyenv-win\versions\3.9.6\Lib\site-packages\pipenv\vendor\pythonfinder\models\path.py”, line 241, in _run_setup path_order=[p.as_posix() for p in path_instances if p.exists()], File “C:\Users\USER.pyenv\pyenv-win\versions\3.9.6\Lib\site-packages\pipenv\vendor\pythonfinder\models\path.py”, line 241, in <listcomp> path_order=[p.as_posix() for p in path_instances if p.exists()], File “c:\users\USER.pyenv\pyenv-win\versions\3.9.6\lib\pathlib.py”, line 1414, in exists self.stat() File “c:\users\USER.pyenv\pyenv-win\versions\3.9.6\lib\pathlib.py”, line 1222, in stat return self._accessor.stat(self) PermissionError: [WinError 5] Access is denied: ‘C:\WINDOWS\system32\config\systemprofile\AppData\Roaming\npm ‘’’

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:21

github_iconTop GitHub Comments

1reaction
mrufsvoldcommented, Apr 1, 2022

Okay, so passing a complete path to a Python executable works. i.e. pipenv install --python c/path/to/python.exe

But after uninstalling/reinstalling, pyenv is not giving me output. It is recognized as a command (I have all of the path variables set up), but when I run

pyenv
pyenv install -l
pyenv --version

They all run without error but show no output.

Obviously, this is far outside the scope of a pipenv issue lol

Seems like it is something broken with my pyenv install to begin with.

Thank you SO much for working through this with me!

1reaction
mrufsvoldcommented, Apr 1, 2022

I just uninstalled Anaconda and all versions of python, uninstalled Node and NPM, and deleted all associated folders that I know of. Then I installed a fresh copy of Miniconda, installed pipenv, ran pipenv install, and got the same error. Shakes fist at the sky

Read more comments on GitHub >

github_iconTop Results From Across the Web

Windows reports error when trying to install package using ...
to my Windows path environment variable, but I still receive the same error. How can I install the requests package using pipenv?
Read more >
Python Pipenv Install: EnvironmentError: Permission Denied
Trying to install python-decouple inside a pipenv shell: (projectname) username@host: pipenv install python-decouple. But I'm getting this following error:
Read more >
serverless-python-requirements - npm
In order to fix that we remove all -e from the generated file but, for that to work you need to add the...
Read more >
pipenv Documentation
Pipenv is a tool that aims to bring the best of all packaging worlds (bundler, composer, npm, cargo, yarn, etc.) to the. Python...
Read more >
Configure a Pipenv environment | PyCharm Documentation
Install Pipenv  · Run the following command: $ py -m site --user-site. A sample output can be: · Replace site-packages with Scripts...
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