pre-commit: python3.7: command not found
If I set language_version: python3.7 rather than language_version: python3, I get the following error. I am using pyenv-virtualenv:
An unexpected error has occurred: CalledProcessError: Command: ('/Users/alex/.pyenv/versions/3.7.0/envs/xxxx/bin/python', '-mvirtualenv', '/Users/alex/.cache/pre-commit/repoxj_919t6/py_env-python3.7', '-p', 'python3.7')
Return code: 127
Expected return code: 0
Output:
repos:
Running virtualenv with interpreter /Users/alex/.pyenv/shims/python3.7
Errors:
pyenv: python3.7: command not found
The `python3.7' command exists in these Python versions:
3.7.0
This may be related to: https://github.com/pyenv/pyenv-virtualenv/issues/206
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 18 (9 by maintainers)
Just adding this here for anyone that comes across this issue.
When you create a virtualenv using, for example,
pyenv virtualenv 3.7.0 example_venv, the commandpython3.7will not work once that virtualenv is activated.In order to make the command
python3.7work in an activated virtualenv, you need to tellpyenv virtualenvwhat additional commands too use.So, to correctly setup the virtualenv to work with pre-commit, run the command as:
pyenv virtualenv -p python3.7 3.7.0 example_venvThis should resolve the issue reported.
Create a symbolic link
Looks like your
python3.7is misconfigured / not installed.I haven’t worked much with
pyenvmyself but I believe you need to do something likepyenv install 3.7.0andpyenv global 3.7.0(or something of the sort? maybe the second one isn’t necessary?)pre-commititself doesn’t have any direct integration withpyenv, though it is known to work with it fine as long as you have things set up properly – notably, pre-commit will callvirtualenv -p $language_versionand if the python referenced bylanguage_versionisn’t functional – well then you’ll see what you’re seeing 😆