This tutorial discusses the
ImportError saying no module named
setuptools and provides a solution to get rid of this error in Python.
setuptools library enhances the standard
distutils Python library and aids in making the building, installation, and upgradation of other Python packages.
Furthermore, it also provides a way to aid in uninstalling the Python packages. This tutorial aims to solve a specific error,
ImportError: No module named setuptools.
setuptools can be more described as a package and not a simple Python package that we mainly refer to, but more of a bundle of software that needs to be installed properly.
Before proceeding with the specified error and resolving it, it is essential to look at and understand a few points that would help ensure the proper installation of the
- You should be able to run Python from the command line.
- You should be able to run the
pipcommands from the command line.
- You should have all the essential components like
setuptoolsup to date.
Now, let’s know the cause of the
ImportError: no module named setuptools error.
Reasons & Solutions for
ImportError Error in Python
ImportError: no module named setuptools error occurs if the
setuptools module is either not installed on the system or if it is incorrectly installed and your Python environment is unable to detect its presence in the system.
To prevent this error, you can make a fresh installation after removing all the contents of
setuptools if there are any. If you had not previously installed
setuptools, you could correctly install the package.
Solution 1: Use the
conda Command to Install
The Anaconda IDE is one of the most popular IDEs programmers use to code in Python. The Anaconda IDE provides a
conda command that we can utilize to install packages.
The following code uses the
conda command to install the
setuptools package to Anaconda IDE.
conda install -c anaconda setuptools
Note that this solution is limited to the Anaconda IDE and cannot be utilized by users looking to install this package in other Python IDEs and notebooks.
Solution 2: Use the
pip Command to Install
pip command covers a broader area and can be utilized to install the
setuptools library in any Python environment.
It is the most straightforward command to install the
setuptools library in any environment or IDEs. The following code fence uses the
pip command to install the
setuptools library in Python.
pip install setuptools