I am quite a newbie when it comes to Python. I am trying to run someone else's code that contains references to pandas_ta. When I run the code I get the following errors:
File "/data/stuart/Projects/Python/BackTesting/Test/Test1.py", line 6, in <module>
import pandas_ta as ta
File "/data/stuart/Projects/Python/Env/lib/python3.12/site-packages/pandas_ta/__init__.py", line 7, in <module>
from pkg_resources import get_distribution, DistributionNotFound
ModuleNotFoundError: No module named 'pkg_resources'
I am running Python 3.10.12 on Ubuntu 22.04 using PyCharm IDE Community version.
As I am a newbie I am somewhat reluctant to try many of the 'answers' I have found on this site until I have an idea as to the likely cause, and best solution. I don't want to make matters worse. What I have tried is the following:
sudo apt-get install --reinstall python-pkg-resources
Unfortunately the problem persists. Unfortunately, I want to use pandas_ta in some other projects as I was unable to get TA-Lib installed correctly. Any guidance or assistance would be much appreciated.
Regards, StuartM
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.
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 setuptools
Verify Installation:
After installation, confirm that pkg_resources is available:
python -c "import pkg_resources; print('pkg_resources is available')"
If the error still occurs:
pip and setuptools:
pip install --upgrade pip setuptools
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With