Pre-commit: FileNotFoundError when running pre-commit

Created on 15 Oct 2020  路  4Comments  路  Source: pre-commit/pre-commit

Any ideas how to better fix the below?

Problem description

Getting this when running pre-commit:

An unexpected error has occurred: CalledProcessError: command: ('c:\\users\\myken\\anaconda3\\envs\\fignal\\python.exe', '-mvirtualenv', 'C:\\Users\\myken\\.cache\\pre-commit\\repow8jbtqz2\\py_env-python', '-p', 'c:\\users\\myken\\anaconda3\\envs\\fignal\\python.exe')
return code: 1
expected return code: 0
stdout:
    FileNotFoundError: [Errno 2] No such file or directory: 'c:\\users\\myken\\anaconda3\\envs\\fignal\\Lib\\venv\\scripts\\nt\\python.exe'

No idea where that c:\\users\\myken\\anaconda3\\envs\\fignal\\Lib\\venv\\scripts\\nt\\python.exe comes from.

I checked the other issues related to python path, but found nothing that applied to my problem.

Environment:

pre-commit -V
pre-commit 2.7.1

conda -V
conda 4.8.3

python --version
Python 3.7.5

which python
C:\Users\myken\Anaconda3\envs\fignal\python.EXE

Get-ComputerInfo | egrep "(OsName|OsBuildN|OsArch)"
OsName                                                  : Microsoft Windows 10 Pro
OsBuildNumber                                           : 18363
OsArchitecture                                          : 64-bit

Here's my .pre-commit-config.yaml:

# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
repos:
-   repo: https://github.com/pre-commit/pre-commit-hooks
    rev: v2.4.0
    hooks:
    # -   id: trailing-whitespace
    # -   id: end-of-file-fixer
    # -   id: check-yaml
    -   id: check-added-large-files

Workaround

cd c:\\users\\myken\\anaconda3\\envs\\fignal\\Lib\\venv\\scripts\\nt\\
sudo cmd /c mklink python.exe C:\Users\myken\Anaconda3\envs\fignal\python.exe
sudo cmd /c mklink pythonw.exe C:\Users\myken\Anaconda3\envs\fignal\pythonw.exe
question upstream-bug

Most helpful comment

If someone else gets here due to the same error and just wants a quick fix, this workaround helped me
https://github.com/ContinuumIO/anaconda-issues/issues/12094#issuecomment-708557750
Basically it says downgrade virtualenv to version 20.0.33
pip install virtualenv==20.0.33

All 4 comments

can you show the contents of the error log and the command you ran and the full output, those details are included intentionally and leaving them out makes me unable to guess at your problem!

this also looks like it's unrelated to pre-commit and you can reproduce the same error with just this:

c:\users\myken\anaconda3\envs\fignal\python.exe -mvirtualenv C:\Users\myken\.cache\pre-commit\repow8jbtqz2\py_env-python -p c:\users\myken\anaconda3\envs\fignal\python.exe

I'd suggest reporting a bug to virtualenv: https://github.com/pypa/virtualenv including information on how you installed virtualenv

If someone else gets here due to the same error and just wants a quick fix, this workaround helped me
https://github.com/ContinuumIO/anaconda-issues/issues/12094#issuecomment-708557750
Basically it says downgrade virtualenv to version 20.0.33
pip install virtualenv==20.0.33

Was this page helpful?
0 / 5 - 0 ratings