July 2018 Update
Most people should now use pip install setuptools (possibly with sudo).
Some may need to (re)install the python-setuptools package via their package manager (apt-get install, yum install, etc.).
This issue can be highly dependent on your OS and dev environment. See the legacy/other answers below if the above isn't working for you.
Explanation
This error message is caused by a missing/broken Python setuptools package. Per Matt M.'s comment and setuptools issue #581, the bootstrap script referred to below is no longer the recommended installation method.
The bootstrap script instructions will remain below, in case it's still helpful to anyone.
Legacy Answer
I encountered the same ImportError today while trying to use pip. Somehow the setuptools package had been deleted in my Python environment.
To fix the issue, run the setup script for setuptools:
wget https://bootstrap.pypa.io/ez_setup.py -O - | python
(or if you don't have wget installed (e.g. OS X), try
curl https://bootstrap.pypa.io/ez_setup.py | python
possibly with sudo prepended.)
If you have any version of distribute, or any setuptools below 0.6, you will have to uninstall it first.*
See Installation Instructions for further details.
* If you already have a working distribute, upgrading it to the "compatibility wrapper" that switches you over to setuptools is easier. But if things are already broken, don't try that.
July 2018 Update
Most people should now use pip install setuptools (possibly with sudo).
Some may need to (re)install the python-setuptools package via their package manager (apt-get install, yum install, etc.).
This issue can be highly dependent on your OS and dev environment. See the legacy/other answers below if the above isn't working for you.
Explanation
This error message is caused by a missing/broken Python setuptools package. Per Matt M.'s comment and setuptools issue #581, the bootstrap script referred to below is no longer the recommended installation method.
The bootstrap script instructions will remain below, in case it's still helpful to anyone.
Legacy Answer
I encountered the same ImportError today while trying to use pip. Somehow the setuptools package had been deleted in my Python environment.
To fix the issue, run the setup script for setuptools:
wget https://bootstrap.pypa.io/ez_setup.py -O - | python
(or if you don't have wget installed (e.g. OS X), try
curl https://bootstrap.pypa.io/ez_setup.py | python
possibly with sudo prepended.)
If you have any version of distribute, or any setuptools below 0.6, you will have to uninstall it first.*
See Installation Instructions for further details.
* If you already have a working distribute, upgrading it to the "compatibility wrapper" that switches you over to setuptools is easier. But if things are already broken, don't try that.
sudo apt-get install --reinstall python-pkg-resources
fixed it for me in Debian. Seems like uninstalling some .deb packages (twisted set in my case) has broken the path python uses to find packages
Impossible to get pkg_resources on Windows?
Why module pkg_resources is not found
`pkg_resources` is deprecated and removed in Python 3.12
Django Error: ModuleNotFoundError: No module named 'pkg_resources'
How do I fix 'ModuleNotFoundError: No module named X'?
What is Python ModuleNotFoundError and what causes it?
Is ModuleNotFoundError the same as ImportError?
I am running on Windows Powershell. I know, it sucks, but it is what I am stuck with.
I have installed python 3.14 from the python.org website. When I run python and run "import setuptools", it works. When I check the version of setuptools, it is 82.0.0. No problems there.
But pkg_resources will not import. Specifically, "import pkg_resources" always fails.
I have reinstalled using --force-reinstall, I have downloaded the setuptools wheel file, none of that works. It just will not recognize pkg_resources.
Is there no pkg_resources file for Windows? Or what on earth is going on here? Every guide I read just keeps repeating that I should reinstall, but I have done that, multiple times, from multiple sources.
Hi everyone,
I'm encountering an error while trying to run my Django project. When I execute python manage.py runserver, I get the following error message:
Watching for file changes with StatReloader
Exception in thread django-main-thread:
Traceback (most recent call last):
File "C:\Python312\Lib\threading.py", line 1052, in _bootstrap_inner
self.run()
File "C:\Python312\Lib\threading.py", line 989, in run
self._target(*self._args, **self._kwargs)
File "C:\Website\my_env\Lib\site-packages\django\utils\autoreload.py", line 64, in wrapper
fn(*args, **kwargs)
File "C:\Website\my_env\Lib\site-packages\django\core\management\commands\runserver.py", line 125, in inner_run
autoreload.raise_last_exception()
File "C:\Website\my_env\Lib\site-packages\django\utils\autoreload.py", line 87, in raise_last_exception
raise _exception[1]
File "C:\Website\my_env\Lib\site-packages\django\core\management\__init__.py", line 394, in execute
autoreload.check_errors(django.setup)()
File "C:\Website\my_env\Lib\site-packages\django\utils\autoreload.py", line 64, in wrapper
fn(*args, **kwargs)
File "C:\Website\my_env\Lib\site-packages\django\__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "C:\Website\my_env\Lib\site-packages\django\apps\registry.py", line 91, in populate
app_config = AppConfig.create(entry)
^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Website\my_env\Lib\site-packages\django\apps\config.py", line 193, in create
import_module(entry)
File "C:\Python312\Lib\importlib\__init__.py", line 90, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "<frozen importlib._bootstrap>", line 1381, in _gcd_import
File "<frozen importlib._bootstrap>", line 1354, in _find_and_load
File "<frozen importlib._bootstrap>", line 1325, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 929, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 994, in exec_module
File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
File "C:\Website\my_env\Lib\site-packages\coreapi\__init__.py", line 2, in <module>
from coreapi import auth, codecs, exceptions, transports, utils
File "C:\Website\my_env\Lib\site-packages\coreapi\auth.py", line 1, in <module>
from coreapi.utils import domain_matches
File "C:\Website\my_env\Lib\site-packages\coreapi\utils.py", line 5, in <module>
import pkg_resources
ModuleNotFoundError: No module named 'pkg_resources'
Here's some additional information that might be helpful:
I'm using Django version 5.0.6.
I've already tried pip install pkg_resources but I get this:
ERROR: Could not find a version that satisfies the requirement pkg_resources (from versions: none)
ERROR: No matching distribution found for pkg_resources
Any insights on what might be causing this and how to fix it would be greatly appreciated!
I got this error when trying to build my love2d game with makelove: * Executing task: C:\Users\Eli\AppData\Local\Programs\Python\Python312\Scripts\makelove.exe --config make_all.toml
Traceback (most recent call last):
File "<frozen runpy>", line 198, in _run_module_as_main
File "<frozen runpy>", line 88, in _run_code
File "C:\Users\Eli\AppData\Local\Programs\Python\Python312\Scripts\makelove.exe\__main__.py", line 4, in <module>
File "C:\Users\Eli\AppData\Local\Programs\Python\Python312\Lib\site-packages\makelove\makelove.py", line 11, in <module>
import pkg_resources
ModuleNotFoundError: No module named 'pkg_resources'
* The terminal process "C:\Users\Eli\AppData\Local\Programs\Python\Python312\Scripts\makelove.exe '--config', 'make_all.toml'" terminated with exit code: 1.
* Terminal will be reused by tasks, press any key to close it.
How do i fix this?
The error indicates that the pkg_resources module, part of the setuptools library, is not available in your Python environment. This module is used by pandas_ta for some of its operations.
Fixing the Issue
To resolve this, ensure that setuptools is installed in your Python environment. You can do this as follows:
Install
setuptools: Run the following command in your terminal:pip install setuptoolsVerify Installation: After installation, confirm that
pkg_resourcesis available:python -c "import pkg_resources; print('pkg_resources is available')"
If the Issue Persists
If the error still occurs:
- Upgrade
pipandsetuptools:pip install --upgrade pip setuptools
Ive been having a similar problem. This might help, though its not definitive. Sadly I havent found a permanent solution as the problem seems to be with the packages/compatibilities.
So, I have program I wrote in pycharm that uses pandas-ta and has worked perfectly for the past year or so... until I tried to improve the code, using a new project with a new interpreter.
I downloaded all the same librares, and used the same (working) code at first, but keep getting an error similar to yours:
UserWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html. The pkg_resources package is slated for removal as early as 2025-11-30. Refrain from using this package or pin to Setuptools<81.
from pkg_resources import get_distribution, DistributionNotFound
I cant find a solution, BUT, when checking google/chatgpt, I kept getting suggestions to downgrade libraries.
On checking, I noticed that although the interpreters use the same packages, and python 3.12, the versions of the packages were different.
In the code that works with pandas_ta, numpy is 1.26.4 and pandas is 2.2.3.
In the new code, thats giving me the error, numpy is 2.3.1 and pandas is 2.3.0.
Its not ideal (and from the date of the post a bit late), but maybe if you downgrade the pandas and/or numpy to these versions, then install pandas_ta, it might work?