Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ImportError: cannot import name 'ParameterSource' from 'click.core'

I'm working on simple flask app, and I received this error

    from click.core import ParameterSource
ImportError: cannot import name 'ParameterSource' from 'click.core' (/usr/local/lib/python3.10/dist-packages/click/core.py)

I don't know why it's appearing, because everything was fine and then just...

Here are versions I use:

black 23.1.0
click 8.1.3
Flask 2.2.3
Python 3.10.6
pip 22.0.2

I've been searching for solution and found that many people can't deal with this problem, and the only advice I found, is that I have to update Click and black to the latest version, but I'm already using the latest version.

What should I do? I there any any way to not use Click at all?

UPDATE

Here is how full error looks like

Traceback (most recent call last):
  File "/usr/lib/python3.10/runpy.py", line 187, in _run_module_as_main
    mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
  File "/usr/lib/python3.10/runpy.py", line 146, in _get_module_details
    return _get_module_details(pkg_main_name, error)
  File "/usr/lib/python3.10/runpy.py", line 110, in _get_module_details
    __import__(pkg_name)
  File "/home/diametr/.local/lib/python3.10/site-packages/flask/__init__.py", line 5, in <module>
    from .app import Flask as Flask
  File "/home/diametr/.local/lib/python3.10/site-packages/flask/app.py", line 34, in <module>
    from . import cli
  File "/home/diametr/.local/lib/python3.10/site-packages/flask/cli.py", line 15, in <module>
    from click.core import ParameterSource
ImportError: cannot import name 'ParameterSource' from 'click.core' (/usr/local/lib/python3.10/dist-packages/click/core.py)
like image 526
Diana Avatar asked Mar 08 '26 19:03

Diana


2 Answers

Please try the following steps:

 pip uninstall black
 pip uninstall click
 pip install black
 pip install click
like image 113
Magaren Avatar answered Mar 11 '26 08:03

Magaren


hopefully enough I found a solution to that. I replaced the installed version with version 8.1.6 Here are the steps

sudo apt purge python3-click
sudo pip install click==8.1.6

This solved that issue for me. Hope it helps you too

like image 28
Julius Mwash Avatar answered Mar 11 '26 09:03

Julius Mwash



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!