Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ipython import error #851

Open
lennart-scale opened this issue Apr 3, 2024 · 0 comments
Open

ipython import error #851

lennart-scale opened this issue Apr 3, 2024 · 0 comments

Comments

@lennart-scale
Copy link

lennart-scale commented Apr 3, 2024

Hi, I have nbqa version 1.85 installed and would like to use it as a pre-commit hook. I am using python 3.8 and manually installed ipython 8.12.0. this is my .pre-commit-config.yaml file

repos:
  - repo: https://github.com/psf/black
    rev: 22.12.0
    hooks:
      - id: black
        name: "python:black"
        entry: black --config .black.toml
        additional_dependencies: ['click<=8.0.4'] 
  - repo: https://github.com/PyCQA/flake8
    rev: 6.0.0
    hooks:
      - id: flake8
        name: "python:flake8"
  - repo: https://github.com/pycqa/isort
    rev: 5.12.0
    hooks:
      - id: isort
        args: ["--settings-path", ".isort.cfg"]
        name: "python:isort"
  - repo: https://github.com/nbQA-dev/nbQA
    rev: 1.8.5
    hooks:
      - id: nbqa-black
        name: "ipynb:black"
        entry: black --config .black.toml
        additional_dependencies: [black==22.12.0]
      - id: nbqa-flake8
        name: "ipynb:flake8"
        additional_dependencies: [flake8==6.0.0]
      - id: nbqa-isort
        name: "ipynb:isort"
        args: ["--settings-path", ".isort.cfg"]
        additional_dependencies: [isort==5.12.0]

When running the hook on a specific ipynb file, pre-commit run --file X.ipynb, I keep getting the following error trace:

- hook id: nbqa-black
- exit code: 1
Traceback (most recent call last):
  File "/home/ubuntu/.cache/pre-commit/reporw3b8p3t/py_env-python3.8/bin/black", line 8, in <module>
    sys.exit(patched_main())
  File "src/black/__init__.py", line 1415, in patched_main
  File "/home/ubuntu/.cache/pre-commit/reporw3b8p3t/py_env-python3.8/lib/python3.8/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
  File "/home/ubuntu/.cache/pre-commit/reporw3b8p3t/py_env-python3.8/lib/python3.8/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
  File "/home/ubuntu/.cache/pre-commit/reporw3b8p3t/py_env-python3.8/lib/python3.8/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/ubuntu/.cache/pre-commit/reporw3b8p3t/py_env-python3.8/lib/python3.8/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
  File "/home/ubuntu/.cache/pre-commit/reporw3b8p3t/py_env-python3.8/lib/python3.8/site-packages/click/decorators.py", line 33, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "src/black/__init__.py", line 562, in main
  File "src/black/__init__.py", line 662, in get_sources
  File "src/black/handle_ipynb_magics.py", line 61, in jupyter_dependencies_are_installed
  File "/home/ubuntu/.cache/pre-commit/reporw3b8p3t/py_env-python3.8/lib/python3.8/site-packages/IPython/__init__.py", line 30, in <module>
    raise ImportError(
ImportError: 
IPython 8.13+ supports Python 3.9 and above, following NEP 29.
IPython 8.0-8.12 supports Python 3.8 and above, following NEP 29.
When using Python 2.7, please install IPython 5.x LTS Long Term Support version.
Python 3.3 and 3.4 were supported up to IPython 6.x.
Python 3.5 was supported with IPython 7.0 to 7.9.
Python 3.6 was supported with IPython up to 7.16.
Python 3.7 was still supported with the 7.x branch.

See IPython `README.rst` file for more information:

    https://github.com/ipython/ipython/blob/main/README.rst

And the same error appears for ipynb:flake8, ipynb:isort. The error message indicates that the ipython version is not compatible with python 3.8. However, the ipython I installed, 8.12.0, is explicitly compatbile. Does something else happen under the hood or does nbqa require a specific ipython/min python version?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant