ImportError: cannot import name ‘_unicodefun’ from ‘click’

We Are Going To Discuss About ImportError: cannot import name ‘_unicodefun’ from ‘click’. So lets Start this Python Article.

ImportError: cannot import name ‘_unicodefun’ from ‘click’

  1. How to solve ImportError: cannot import name '_unicodefun' from 'click'

    This has been fixed by Black 22.3.0. Versions before that won't work with click 8.1.0.
    Incompatible with click 8.1.0 (ImportError: cannot import name '_unicodefun' from 'click') #2964
    E.g.: black.yml
    python-version: 3.8 - name: install black run: | - pip install black==20.8b1 + pip install black==22.3.0 - name: run black run: | black . --check --line-length 100
    https://github.com/Clinical-Genomics/cgbeacon2/pull/221/files
    As a workaround, pin click to the last version via pip install --upgrade click==8.0.2.

  2. ImportError: cannot import name '_unicodefun' from 'click'

    This has been fixed by Black 22.3.0. Versions before that won't work with click 8.1.0.
    Incompatible with click 8.1.0 (ImportError: cannot import name '_unicodefun' from 'click') #2964
    E.g.: black.yml
    python-version: 3.8 - name: install black run: | - pip install black==20.8b1 + pip install black==22.3.0 - name: run black run: | black . --check --line-length 100
    https://github.com/Clinical-Genomics/cgbeacon2/pull/221/files
    As a workaround, pin click to the last version via pip install --upgrade click==8.0.2.

Solution 1

This has been fixed by Black 22.3.0. Versions before that won’t work with click 8.1.0.

Incompatible with click 8.1.0 (ImportError: cannot import name ‘_unicodefun’ from ‘click’) #2964

E.g.: black.yml

          python-version: 3.8
      - name: install black
        run: |
-          pip install black==20.8b1
+          pip install black==22.3.0
      - name: run black
        run: |
          black . --check --line-length 100

https://github.com/Clinical-Genomics/cgbeacon2/pull/221/files

As a workaround, pin click to the last version via pip install --upgrade click==8.0.2.

Original Author edited May 5 at 10:15 Of This Content

Solution 2

If you’re using black as part of a pre-commit hook’s YAML, you can update the pre-commit file (often .pre-commit-config.yaml ) to reference the more recent versions of black (>=22.3.0), e.g.

# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
repos:
-   repo: https://github.com/pre-commit/pre-commit-hooks
    rev: v3.2.0
    hooks:
    -   id: trailing-whitespace
    -   id: end-of-file-fixer
    -   id: check-yaml
    -   id: check-added-large-files
-   repo: https://github.com/psf/black
    rev: 22.3.0
    hooks:
    -   id: black
        exclude: ^dist/

Running pip install of a new version of black won’t be sufficient for command-line pre-commit hooks if the YAML file pins black itself to a particular version… which pre-commit does by default. See also Black’s GitHub Issue Tracker.

Original Author Sarah Messer Of This Content

Solution 3

If none of the above works, you might have some trouble-making cache from previous changes in your code. Try running:

pre-commit clean

pre-commit autoupdate

Original Author pariya Of This Content

Conclusion

So This is all About This Tutorial. Hope This Tutorial Helped You. Thank You.

Also Read,

ittutorial team

I am an Information Technology Engineer. I have Completed my MCA And I have 4 Year Plus Experience, I am a web developer with knowledge of multiple back-end platforms Like PHP, Node.js, Python and frontend JavaScript frameworks Like Angular, React, and Vue.

Leave a Comment