import numpy as np
from codecarbon import EmissionsTracker
tracker = EmissionsTracker()
tracker.start()
for i in range(100):
A = np.random.rand(100,100)
B = np.random.rand(100,100)
C = A*B
emissions: float = tracker.stop()
print(emissions)
See an error trace similar to what is shown above. If you then do pip install setuptools in the venv, it can work.
Description
Running a simple script leads to the error trace:
This shows that it is trying to import the
pkg_resources
package, but it was removed from the main installation and moved to setuptools in Python 3.12. You should either declare a dependency onsetuptools
to ensure it is installed, or switch away from usingpkg_resources
(since it is deprecated in favor of the importlib package: https://importlib-resources.readthedocs.io/en/latest/migration.html#pkg-resources-resource-filename).What I Did
pip install codecarbon
See an error trace similar to what is shown above. If you then do
pip install setuptools
in the venv, it can work.