Search code examples
jupyterhubpre-commit.com

pre-commit run The path python3.6 (from --python=python3.6) does not exist


I am trying to follow the contributing docs for JupyterHub and am getting an error when I run pre-commit run

The error is related to my python version. It's expecting 3.6 for some reason even though everything was installed with Python 3.7.3. Here is the output running the command:

(.hub)  {~/jupyter/jupyterhub} (master %)$  pre-commit run
[INFO] Initializing environment for https://github.com/asottile/reorder_python_imports.
[INFO] Initializing environment for https://github.com/ambv/black.
[INFO] Initializing environment for https://github.com/pre-commit/pre-commit-hooks.
[INFO] Installing environment for https://github.com/asottile/reorder_python_imports.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
An unexpected error has occurred: CalledProcessError: Command: ('/Users/nicholasbrady/jupyter/jupyterhub/.hub/bin/python3', '-mvirtualenv', '/Users/nicholasbrady/.cache/pre-commit/repo5hv9ofak/py_env-python3.6', '-p', 'python3.6')
Return code: 3
Expected return code: 0
Output: 
    The path python3.6 (from --python=python3.6) does not exist

Errors: (none)

Check the log at /Users/nicholasbrady/.cache/pre-commit/pre-commit.log

If I check the logs, this is what it says:

(.hub)  {~/jupyter/jupyterhub} (master %)$  cat /Users/nicholasbrady/.cache/pre-commit/pre-commit.log
An unexpected error has occurred: CalledProcessError: Command: ('/Users/nicholasbrady/jupyter/jupyterhub/.hub/bin/python3', '-mvirtualenv', '/Users/nicholasbrady/.cache/pre-commit/repo5hv9ofak/py_env-python3.6', '-p', 'python3.6')
Return code: 3
Expected return code: 0
Output: 
    The path python3.6 (from --python=python3.6) does not exist

Errors: (none)

Traceback (most recent call last):
  File "/Users/nicholasbrady/jupyter/jupyterhub/.hub/lib/python3.7/site-packages/pre_commit/error_handler.py", line 46, in error_handler
    yield
  File "/Users/nicholasbrady/jupyter/jupyterhub/.hub/lib/python3.7/site-packages/pre_commit/main.py", line 316, in main
    return run(args.config, store, args)
  File "/Users/nicholasbrady/jupyter/jupyterhub/.hub/lib/python3.7/site-packages/pre_commit/commands/run.py", line 295, in run
    install_hook_envs(hooks, store)
  File "/Users/nicholasbrady/jupyter/jupyterhub/.hub/lib/python3.7/site-packages/pre_commit/repository.py", line 215, in install_hook_envs
    hook.install()
  File "/Users/nicholasbrady/jupyter/jupyterhub/.hub/lib/python3.7/site-packages/pre_commit/repository.py", line 93, in install
    self.prefix, self.language_version, self.additional_dependencies,
  File "/Users/nicholasbrady/jupyter/jupyterhub/.hub/lib/python3.7/site-packages/pre_commit/languages/python.py", line 168, in install_environment
    _make_venv(env_dir, python)
  File "/Users/nicholasbrady/jupyter/jupyterhub/.hub/lib/python3.7/site-packages/pre_commit/languages/python.py", line 180, in make_venv
    cmd_output(*cmd, env=env, cwd='/')
  File "/Users/nicholasbrady/jupyter/jupyterhub/.hub/lib/python3.7/site-packages/pre_commit/util.py", line 153, in cmd_output
    returncode, cmd, retcode, output=(stdout, stderr),
pre_commit.util.CalledProcessError: Command: ('/Users/nicholasbrady/jupyter/jupyterhub/.hub/bin/python3', '-mvirtualenv', '/Users/nicholasbrady/.cache/pre-commit/repo5hv9ofak/py_env-python3.6', '-p', 'python3.6')
Return code: 3
Expected return code: 0
Output: 
    The path python3.6 (from --python=python3.6) does not exist

Errors: (none)


I tried to clear the cache since it looked like it was referring to a cache that might have existed when I had python 3.6

(.hub)  {~/jupyter/jupyterhub} (master %)$  pre-commit clean
Cleaned /Users/nicholasbrady/.cache/pre-commit.

but it didn't change the error at all, or the log.

Anyone know what this is? If not, hopefully I'll figure out soon and will add an answer when I do... :)


Solution

  • The configuration for that repository sets language_version: python3.6 which is why it is attempting to use python3.6

    I'd suggest either changing that to language_version: python3 or installing python3.6