How To Fix Python Importerror: No Module Named Setuptools

When I run my python code, I meet an import error. The error message is ImportError: No module named setuptools. The reason for this error is because we do not install the python setuptools module, so to fix it, we just need to install the python setuptools module.

1. Install Python setuptools Module.

  1. First, we should download the python setuptools package. Open a terminal and run the below wget command to download the python setuptools module.
    l# wget
  2. Run tar command to unpack the downloaded package.
    # unpack setuptools package.
    # tar zxvf setuptools-0.6c11.tar.gz
    # goto unpacked directory
    # cd setuptools-0.6c1
  3. Compile setuptools with python build command.
    # python build
  4. Install setuptools package use python install command. After you complete the installation, the error will be fixed.
    # python install

2. Question & Answer.

2.1 How to fix the python no module named ‘setuptools’ error on macOS.

  1. My python is installed o macOS X, the python version is 3.6. I want to install the python library pysparse on it, but when I run the command python install to install it, it always returns the error message ImportError: No module named ‘setuptools’. How can I fix this error? Thanks.
  2. First, you can run the command python -m pip --version to check whether you have installed pip on your macOS or not.
    $ python -m pip --version
    pip 21.0.1 from /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pip (python 3.7)

    If you installed pip in your macOS, you can run the command pip install setuptools to install the setuptools. If your macOS has not installed pip, you can follow the below steps to install it.
    Run the below command in a terminal to download the file.

    curl -o

    Then run the command python for Unix/macOS, or py for Windows to install the pip.

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.