ModuleNotFoundError: No module named 'click' in Python

Dung Do Tien Aug 11 2022 72

Hy Guys,

I have a small Python project. In my project, I installed the click package for creating beautiful command line interfaces in a composable way with as little code as necessary. You can see some lines of code like this:

 import click
@click.option("--count", default=1, help="Number of counting.")
@click.option("--name", prompt="Your name", help="The person to count.")
def hello(count, name):
    for _ in range(count):
        click.echo(f"Hello, {name}!")

if __name__ == '__main__':

It still work well on my desktop, but when cloned from Github into my laptop, I got an issue : ModuleNotFoundError: No module named 'click'. Here is the detail of the error:

 Traceback (most recent call last):
  File "", line 1, in <module>
    import click
ModuleNotFoundError: No module named 'click'

** Process exited - Return Code: 1 **
Press Enter to exit terminal

I use Python 3.10 and Click version 8.0.2.

Thanks for any answer

Have 2 answer(s) found.
  • G

    Gabriel Mandap Aug 11 2022

    You can open your terminal in your project's root directory and install the click module.

     # 👇️ in a virtual environment or using Python 2
    pip install click
    # 👇️ for python 3 (could also be pip3.10 depending on your version)
    pip3 install click
    # 👇️ if you get permissions error
    sudo pip3 install click
    # 👇️ if you don't have pip in your PATH environment variable
    python -m pip install click
    # 👇️ for python 3 (could also be pip3.10 depending on your version)
    python3 -m pip install click
    # 👇️ for Anaconda
    conda install -c anaconda click
  • A

    Aashish Thapa Magar Aug 11 2022

    After cloning from Github, I think you can reinstall click package, you can get the library directly from PyPI:

     pip install click

    Hope this can help you.

Leave An Answer
* NOTE: You need Login before leave an answer

* Type maximum 2000 characters.

* All comments have to wait approved before display.

* Please polite comment and respect questions and answers of others.

Popular Tips

X Close