conda-forge / conda-forge/pre-commit-feedstock
ModuleNotFoundError: No module named 'pre_commit' for v4.0.1 and Python 3.13
- Dominant language
- Batchfile
- Stars
- 1
- Forks
- 7
- PR merge metrics
- No merged PRs in 30d
Description
### Solution to issue cannot be found in the documentation.
- [x] I checked the documentation.
### Issue
If `pre-commit` is installed with no constraints on Python so that it gets Python 3.13, `pre-commit --help` fails with
```pytb
Traceback (most recent call last):
File "/tmp/example/.pixi/envs/default/bin/pre-commit", line 6, in
from pre_commit.main import main
ModuleNotFoundError: No module named 'pre_commit'
```
## Minimal failing example
```console
$ mkdir example && cd example
$ pixi init
$ pixi add pre-commit
✔ Added pre-commit >=4.0.1,<5
$ pixi run pre-commit --help
Traceback (most recent call last):
File "/tmp/example/.pixi/envs/default/bin/pre-commit", line 6, in
from pre_commit.main import main
ModuleNotFoundError: No module named 'pre_commit'
$ pixi list | grep 'pre-commit\|python'
pre-commit 4.0.1 pyha770c72_1 189.1 KiB conda pre-commit
python 3.13.1 ha99a958_103_cp313 31.7 MiB conda python
python_abi 3.13 5_cp313 6.1 KiB conda python_abi
```
## Minimal working example
```console
$ mkdir example && cd example
$ pixi init
$ pixi add pre-commit 'python=3.12'
✔ Added pre-commit >=4.0.1,<5
✔ Added python=3.12
$ pixi run pre-commit --help
usage: pre-commit [-h] [-V] {autoupdate,clean,gc,init-templatedir,install,install-hooks,migrate-config,run,sample-config,try-repo,uninstall,validate-config,validate-manifest,help,hook-impl} ...
positional arguments:
{autoupdate,clean,gc,init-templatedir,install,install-hooks,migrate-config,run,sample-config,try-repo,uninstall,validate-config,validate-manifest,help,hook-impl}
autoupdate Auto-update pre-commit config to the latest repos' versions.
clean Clean out pre-commit files.
gc Clean unused cached repos.
init-templatedir Install hook script in a directory intended for use with `git config init.templateDir`.
install Install the pre-commit script.
install-hooks Install hook environments for all environments in the config file. You may find `pre-commit install --install-hooks` more useful.
migrate-config Migrate list configuration to new map configuration.
run Run hooks.
sample-config Produce a sample .pre-commit-config.yaml file
try-repo Try the hooks in a repository, useful for developing new hooks.
uninstall Uninstall the pre-commit script.
validate-config Validate .pre-commit-config.yaml files
validate-manifest Validate .pre-commit-hooks.yaml files
help Show help for a specific command.
options:
-h, --help show this help message and exit
-V, --version show program's version number and exit
$ pixi list | grep 'pre-commit\|python'
pre-commit 4.0.1 pyha770c72_1 189.1 KiB conda pre-commit
python 3.12.8 h9e4cc4f_1_cpython 30.1 MiB conda python
python_abi 3.12 5_cp312 6.1 KiB conda python_abi
```
cc @kratsg who first reported this.
### Installed packages
```shell
Package Version Build Size Kind Source
_libgcc_mutex 0.1 conda_forge 2.5 KiB conda _libgcc_mutex
_openmp_mutex 4.5 2_gnu 23.1 KiB conda _openmp_mutex
bzip2 1.0.8 h4bc722e_7 246.9 KiB conda bzip2
ca-certificates 2024.12.14 hbcca054_0 153.4 KiB conda ca-certificates
cffi 1.17.1 py313hfab6e84_0 288.6 KiB conda cffi
cfgv 3.3.1 pyhd8ed1ab_1 12.7 KiB conda cfgv
distlib 0.3.9 pyhd8ed1ab_1 267.7 KiB conda distlib
filelock 3.16.1 pyhd8ed1ab_1 17 KiB conda filelock
identify 2.6.5 pyhd8ed1ab_0 76.6 KiB conda identify
ld_impl_linux-64 2.43 h712a8e2_2 653.5 KiB conda ld_impl_linux-64
libexpat 2.6.4 h5888daf_0 71.6 KiB conda libexpat
libffi 3.4.2 h7f98852_5 56.9 KiB conda libffi
libgcc 14.2.0 h77fa898_1 828.9 KiB conda libgcc
libgcc-ng 14.2.0 h69a702a_1 52.9 KiB conda libgcc-ng
libgomp 14.2.0 h77fa898_1 450.2 KiB conda libgomp
liblzma 5.6.3 hb9d3cd8_1 108.5 KiB conda liblzma
libmpdec 4.0.0 h4bc722e_0 87.9 KiB conda libmpdec
libsqlite 3.47.2 hee588c1_0 853.1 KiB conda libsqlite
libstdcxx 14.2.0 hc0a3c3a_1 3.7 MiB conda libstdcxx
libuuid 2.38.1 h0b41bf4_0 32.8 KiB conda libuuid
libzlib 1.3.1 hb9d3cd8_2 59.5 KiB conda libzlib
ncurses 6.5 he02047a_1 868.2 KiB conda ncurses
nodeenv 1.9.1 pyhd8ed1ab_1 33.8 KiB conda nodeenv
openssl 3.4.0 h7b32b05_1 2.8 MiB conda openssl
platformdirs 4.3.6 pyhd8ed1ab_1 20 KiB conda platformdirs
pre-commit 4.0.1 pyha770c72_1 189.1 KiB conda pre-commit
pycparser 2.22 pyh29332c3_1 107.5 KiB conda pycparser
python 3.13.1 ha99a958_103_cp313 31.7 MiB conda python
python_abi 3.13 5_cp313 6.1 KiB conda python_abi
pyyaml 6.0.2 py313h536fd9c_1 201 KiB conda pyyaml
readline 8.2 h8228510_1 274.9 KiB conda readline
setuptools 75.6.0 pyhff2d567_1 756.1 KiB conda setuptools
tk 8.6.13 noxft_h4845f30_101 3.2 MiB conda tk
tzdata 2024b hc8b5060_0 119.5 KiB conda tzdata
ukkonen 1.0.1 py313h33d0bda_5 13.6 KiB conda ukkonen
virtualenv 20.28.1 pyhd8ed1ab_0 3.2 MiB conda virtualenv
yaml 0.2.5 h7f98852_2 87.1 KiB conda yaml
```
### Environment info
```shell
System
------------
Pixi version: 0.39.5
Platform: linux-64
Virtual packages: __unix=0=0
: __linux=6.8.0=0
: __glibc=2.35=0
: __cuda=12.2=0
: __archspec=1=skylake
Cache dir: /home/feickert/.cache/rattler/cache
Auth storage: /home/feickert/.rattler/credentials.json
Config locations: No config files found
Global
------------
Bin dir: /home/feickert/.pixi/bin
Environment dir: /home/feickert/.pixi/envs
Manifest dir: /home/feickert/.pixi/manifests/pixi-global.toml
Project
------------
Name: example
Version: 0.1.0
Manifest file: /tmp/example/pixi.toml
Last updated: 07-01-2025 21:27:07
Environments
------------
Environment: default
Features: default
Channels: conda-forge
Dependency count: 1
Dependencies: pre-commit
Target platforms: linux-64
```
Contributor guide
Assessment
This issue has not been assessed yet.