Pre-commit + conda on win10 looks for python in a wrong location
See original GitHub issueI have a problem similar to #1583, but I cannot find an easy way to fix it.
I am using conda, so my python is located in c:\\tools\\miniconda3\\python.exe
. When I try to install the pre-commit hooks, the pre-commit file is created alright, with python pointing to the right location:
#!/usr/bin/env python
"""File generated by pre-commit: https://pre-commit.com"""
from __future__ import print_function
import distutils.spawn
import os
import subprocess
import sys
# work around https://github.com/Homebrew/homebrew-core/issues/30445
os.environ.pop('__PYVENV_LAUNCHER__', None)
HERE = os.path.dirname(os.path.abspath(__file__))
Z40 = '0' * 40
ID_HASH = '138fd403232d2ddd5efb44317e38bf03'
# start templated
CONFIG = '.pre-commit-config.yaml'
HOOK_TYPE = 'pre-commit'
INSTALL_PYTHON = 'c:\\tools\\miniconda3\\python.exe'
SKIP_ON_MISSING_CONFIG = False
# end templated
class EarlyExit(RuntimeError):
pass
class FatalError(RuntimeError):
pass
...
However, when I try to commit, for some reason pre-commit is searching for python elsewhere:
✗ git commit
[INFO] Installing environment for https://github.com/ambv/black.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
An unexpected error has occurred: CalledProcessError: Command: ('c:\\tools\\miniconda3\\python.exe', '-mvirtualenv',
'C:\\Users\\user\\.cache\\pre-commit\\repo6nh7djva\\py_env-python3', '-p', 'C:\\python3\\python.exe')
Return code: 1
Expected return code: 0
Output:
FileNotFoundError: [WinError 3] The system cannot find the path specified: 'C:\\python3\\python.exe'
Errors: (none)
Check the log at C:\Users\user/.cache\pre-commit\pre-commit.log
I’ve tried to fix it manually, but I am not sure where it takes this python location from. All references in pre-commit
point to the correct location (including just typing python
in the terminal). The folder C:\\python3\\python.exe
does not exist on my system (since python is installed by conda), so it cannot be on the system path.
I will appreciate any advice, thank you.
Issue Analytics
- State:
- Created 3 years ago
- Comments:8 (5 by maintainers)
Top Results From Across the Web
pre-commit
Add a file called .pre-commit-config.yaml to the root of your project. The pre-commit config file describes what repositories and hooks are installed.
Read more >Pre-commit not finding python packages
We have some extra linting rules but not any config file(s) for pre-commit that I can find.. neither in repo or my home...
Read more >Develop with Conda on Windows
If you have problems change the maximum number of parallel project builds to 1 in Visual Studio in Tools -> Options -> Projects...
Read more >conda can't connect to https url because the ssl module is ...
The problem is that Anaconda Python ships with its own SSL libraries and does not use the ... search for the OpenSSL DLLs...
Read more >Building from source - JAX documentation
Building JAX involves two steps: Building or installing jaxlib , the C++ support library for jax . Installing the jax Python package.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
you’re also using a really old version of pre-commit which won’t try sys.executable so maybe try upgrading
one of your hooks is setting
language_version: python3
and is performing the lookup to find that (and failing)