black icon indicating copy to clipboard operation
black copied to clipboard

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

Open omonimus1 opened this issue 3 years ago • 11 comments

Installed multiple times on different project. Latest version( 22.3.0) gives the following error when lunched

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

omonimus1 avatar Jun 07 '22 09:06 omonimus1

This should be fixed in the latest version. What version of Click are you using?

JelleZijlstra avatar Jun 07 '22 14:06 JelleZijlstra

@JelleZijlstra click==8.1.2 black==22.3.0

omonimus1 avatar Jun 08 '22 11:06 omonimus1

Same here for click==8.1.3 and black==22.3.0

cgkr avatar Jun 09 '22 10:06 cgkr

Which versions do I need to make it work? Is there a version of click that I can pin to to fix it?

nottrobin avatar Jun 14 '22 08:06 nottrobin

I'm going to need a self-contained reproducer if we are ever going to figure out the root of the problem since I can't reproduce it locally:

~/programming/testing/click-parametersource 
1% ❯ python -m virtualenv venv ; . venv/bin/activate.fish ; python -m pip install black==22.3.0 click==8.1.2
created virtual environment CPython3.8.5.final.0-64 in 1726ms
  creator CPython3Posix(dest=/home/ichard26/programming/testing/click-parametersource/venv, clear=False, no_vcs_ignore=False, global=False)
  seeder FromAppData(download=False, pip=bundle, setuptools=bundle, wheel=bundle, via=copy, app_data_dir=/home/ichard26/.local/share/virtualenv)
    added seed packages: pip==22.1.2, setuptools==62.3.3, wheel==0.37.1
  activators BashActivator,CShellActivator,FishActivator,NushellActivator,PowerShellActivator,PythonActivator
Collecting black==22.3.0
  Using cached black-22.3.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.5 MB)
Collecting click==8.1.2
  Using cached click-8.1.2-py3-none-any.whl (96 kB)
Collecting platformdirs>=2
  Using cached platformdirs-2.5.2-py3-none-any.whl (14 kB)
Collecting mypy-extensions>=0.4.3
  Using cached mypy_extensions-0.4.3-py2.py3-none-any.whl (4.5 kB)
Collecting pathspec>=0.9.0
  Using cached pathspec-0.9.0-py2.py3-none-any.whl (31 kB)
Collecting tomli>=1.1.0
  Using cached tomli-2.0.1-py3-none-any.whl (12 kB)
Collecting typing-extensions>=3.10.0.0
  Using cached typing_extensions-4.2.0-py3-none-any.whl (24 kB)
Installing collected packages: mypy-extensions, typing-extensions, tomli, platformdirs, pathspec, click, black
Successfully installed black-22.3.0 click-8.1.2 mypy-extensions-0.4.3 pathspec-0.9.0 platformdirs-2.5.2 tomli-2.0.1 typing-extensions-4.2.0

~/programming/testing/click-parametersource via Python v3.8.5 (venv) took 9s943ms 
2% ❯ black --version
black, 22.3.0 (compiled: yes)

Checking click 8.1.2 on GitHub, click.core.ParameterSource does indeed exist ... *shrug*

Please provide environment details (OS, architecture, Python version, etc.) and provide steps that show this crash. Even better if a Dockerfile can be provided. Thank you!

ichard26 avatar Jun 15 '22 20:06 ichard26

+1 I had 22.3.0 but I solved it installing black-21.4b0

denadai2 avatar Jun 16 '22 12:06 denadai2

Same error with me

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

OS: Win10 Pro Architecture: 64bit Python version: 3.9.6

Eunit99 avatar Jul 01 '22 09:07 Eunit99

Please uninstall black and click, Then install both to its the latest version will solve this issue. pip uninstall black pip uninstall click then pip install black pip install click

nimishathekkarathlooper avatar Jul 07 '22 10:07 nimishathekkarathlooper

Edited: Red herring, as the failure comes from an older click install in ~/.local on my dev linux machine

~Same issue for me, here's a conda environment:~

environment.yaml
name: psf-black-issue-3111
channels:
  - bioconda
  - conda-forge
  - defaults
dependencies:
  - _libgcc_mutex=0.1=conda_forge
  - _openmp_mutex=4.5=2_gnu
  - amply=0.1.5=pyhd8ed1ab_0
  - appdirs=1.4.4=pyh9f0ad1d_0
  - attrs=21.4.0=pyhd8ed1ab_0
  - bedtools=2.30.0=h468198e_3
  - biopython=1.79=py39hb9d737c_2
  - black=22.6.0=pyhd8ed1ab_0
  - brotlipy=0.7.0=py39hb9d737c_1004
  - bzip2=1.0.8=h7f98852_4
  - c-ares=1.18.1=h7f98852_0
  - ca-certificates=2022.6.15=ha878542_0
  - certifi=2022.6.15=py39hf3d152e_0
  - cffi=1.15.1=py39he91dace_0
  - charset-normalizer=2.1.0=pyhd8ed1ab_0
  - click=8.1.3=py39hf3d152e_0
  - coin-or-cbc=2.10.8=h3786ebc_0
  - coin-or-cgl=0.60.6=he2f9439_0
  - coin-or-clp=1.17.6=h256e9bb_3
  - coin-or-osi=0.108.7=h3b589db_0
  - coin-or-utils=2.11.6=h202d8b1_1
  - coincbc=2.10.8=0_metapackage
  - colorama=0.4.5=pyhd8ed1ab_0
  - configargparse=1.5.3=pyhd8ed1ab_0
  - connection_pool=0.0.3=pyhd3deb0d_0
  - cryptography=37.0.2=py39hd97740a_0
  - cython=0.29.30=py39h5a03fae_0
  - dataclasses=0.8=pyhc8e2a94_3
  - datrie=0.8.2=py39h3811e60_3
  - decorator=5.1.1=pyhd8ed1ab_0
  - defopt=6.3.0=pyhd8ed1ab_0
  - docutils=0.19=py39hf3d152e_0
  - dpath=2.0.6=py39hf3d152e_1
  - filelock=3.7.1=pyhd8ed1ab_0
  - flake8=4.0.1=pyhd8ed1ab_2
  - future=0.18.2=py39hf3d152e_5
  - gitdb=4.0.9=pyhd8ed1ab_0
  - gitpython=3.1.27=pyhd8ed1ab_0
  - idna=3.3=pyhd8ed1ab_0
  - importlib-metadata=4.11.4=py39hf3d152e_0
  - importlib_resources=5.8.0=pyhd8ed1ab_0
  - iniconfig=1.1.1=pyh9f0ad1d_0
  - intervaltree=3.1.0=pyhd3eb1b0_0
  - jinja2=3.1.2=pyhd8ed1ab_1
  - jsonschema=4.6.1=pyhd8ed1ab_0
  - jupyter_core=4.10.0=py39hf3d152e_0
  - keyutils=1.6.1=h166bdaf_0
  - krb5=1.19.3=h3790be6_0
  - ld_impl_linux-64=2.36.1=hea4e1c9_2
  - libblas=3.9.0=15_linux64_openblas
  - libcblas=3.9.0=15_linux64_openblas
  - libcurl=7.83.1=h7bff187_0
  - libdeflate=1.10=h7f98852_0
  - libedit=3.1.20191231=he28a2e2_2
  - libev=4.33=h516909a_1
  - libffi=3.4.2=h7f98852_5
  - libgcc-ng=12.1.0=h8d9b700_16
  - libgfortran-ng=12.1.0=h69a702a_16
  - libgfortran5=12.1.0=hdcd56e2_16
  - libgomp=12.1.0=h8d9b700_16
  - liblapack=3.9.0=15_linux64_openblas
  - liblapacke=3.9.0=15_linux64_openblas
  - libnghttp2=1.47.0=h727a467_0
  - libnsl=2.0.0=h7f98852_0
  - libopenblas=0.3.20=pthreads_h78a6416_0
  - libssh2=1.10.0=ha56f1ee_2
  - libstdcxx-ng=12.1.0=ha89aaad_16
  - libuuid=2.32.1=h7f98852_1000
  - libzlib=1.2.12=h166bdaf_1
  - markupsafe=2.1.1=py39hb9d737c_1
  - mccabe=0.6.1=py_1
  - mypy=0.961=py39hb9d737c_0
  - mypy_extensions=0.4.3=py39hf3d152e_5
  - nbformat=5.4.0=pyhd8ed1ab_0
  - ncurses=6.3=h27087fc_1
  - numpy=1.23.0=py39hba7629e_0
  - openjdk=8.0.192=h516909a_1005
  - openssl=1.1.1q=h166bdaf_0
  - packaging=21.3=pyhd8ed1ab_0
  - pandas=1.4.3=py39h1832856_0
  - pathspec=0.9.0=pyhd8ed1ab_0
  - pip=22.1.2=pyhd8ed1ab_0
  - plac=1.3.5=pyhd8ed1ab_0
  - platformdirs=2.5.1=pyhd8ed1ab_0
  - pluggy=1.0.0=py39hf3d152e_3
  - pockets=0.9.1=py_0
  - psutil=5.9.1=py39hb9d737c_0
  - pulp=2.6.0=py39hf3d152e_1
  - py=1.11.0=pyh6c4a22f_0
  - pybedlite=0.0.1=pyhdfd78af_1
  - pybedtools=0.9.0=py39h6935b12_1
  - pybiomart=0.2.0=pyh864c0ab_1
  - pycodestyle=2.8.0=pyhd8ed1ab_0
  - pycparser=2.21=pyhd8ed1ab_0
  - pyfaidx=0.7.0=pyh5e36f6f_0
  - pyflakes=2.4.0=pyhd8ed1ab_0
  - pyopenssl=22.0.0=pyhd8ed1ab_0
  - pyparsing=3.0.9=pyhd8ed1ab_0
  - pyrsistent=0.18.1=py39hb9d737c_1
  - pysam=0.19.1=py39h5030a8b_0
  - pysocks=1.7.1=py39hf3d152e_5
  - pytest=7.1.2=py39hf3d152e_0
  - python=3.9.13=h9a8a25e_0_cpython
  - python-dateutil=2.8.2=pyhd8ed1ab_0
  - python-fastjsonschema=2.15.3=pyhd8ed1ab_0
  - python_abi=3.9=2_cp39
  - pytz=2022.1=pyhd8ed1ab_0
  - pyyaml=6.0=py39hb9d737c_4
  - ratelimiter=1.2.0=py_1002
  - readline=8.1.2=h0f457ee_0
  - regex=2022.6.2=py39hb9d737c_0
  - requests=2.28.1=pyhd8ed1ab_0
  - requests_cache=0.4.13=py_0
  - retry=0.9.2=py_0
  - samwell=0.0.4=py39hbf8eff0_0
  - setuptools=63.1.0=py39hf3d152e_0
  - six=1.16.0=pyh6c4a22f_0
  - smart_open=6.0.0=pyhd8ed1ab_0
  - smmap=3.0.5=pyh44b312d_0
  - snakemake-minimal=7.8.5=pyhdfd78af_0
  - sortedcontainers=2.4.0=pyhd8ed1ab_0
  - sphinxcontrib-napoleon=0.7=py_0
  - sqlite=3.39.0=h4ff8645_0
  - stopit=1.1.2=py_0
  - tabulate=0.8.10=pyhd8ed1ab_0
  - tk=8.6.12=h27826a3_0
  - toml=0.10.2=pyhd8ed1ab_0
  - tomli=2.0.1=pyhd8ed1ab_0
  - toposort=1.7=pyhd8ed1ab_0
  - traitlets=5.3.0=pyhd8ed1ab_0
  - typed-ast=1.5.4=py39hb9d737c_0
  - types-pyyaml=6.0.9=pyhd8ed1ab_0
  - typing_extensions=4.3.0=pyha770c72_0
  - typing_inspect=0.7.1=pyh6c4a22f_0
  - tzdata=2022a=h191b570_0
  - urllib3=1.26.9=pyhd8ed1ab_0
  - wheel=0.37.1=pyhd8ed1ab_0
  - wrapt=1.14.1=py39hb9d737c_0
  - xz=5.2.5=h516909a_1
  - yaml=0.2.5=h7f98852_2
  - yte=1.5.1=py39hf3d152e_0
  - zipp=3.8.0=pyhd8ed1ab_0
  - zlib=1.2.12=h166bdaf_1

nh13 avatar Jul 07 '22 18:07 nh13

Experienced the same as @nh13! Thanks for the hint. Updating click in local solved the problem for me.

DanielSzym avatar Jul 15 '22 09:07 DanielSzym

Try restarting the kernel! It worked for me both in Colab and Kaggle

raisa314 avatar Sep 16 '22 00:09 raisa314

No actionable issue here.

JelleZijlstra avatar Dec 20 '22 02:12 JelleZijlstra

Same as @nh13 , solved it by uninstalling black outside the conda environment.

luczeng avatar Feb 11 '23 15:02 luczeng