esutil
esutil copied to clipboard
Installation from pip on a clean system is broken
When installing on a clean system using pip install esutil
the installation goes fine, but the package cannot be imported.
The error is:
root@836b9e6d53c4:/# python3 -c 'import esutil'
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/usr/local/lib/python3.10/dist-packages/esutil/__init__.py", line 104, in <module>
from . import integrate
ImportError: cannot import name 'integrate' from partially initialized module 'esutil' (most likely due to a circular import) (/usr/local/lib/python3.10/dist-packages/esutil/__init__.py)
Steps to replicate (using Ubuntu docker image as an example, just to have a clean system - but it manifests on other distributions as well):
docker run -it ubuntu
> apt update
> apt install python3-pip
> pip3 install esutil
> python3 -c 'import esutil'
I didn't try docker, but the following works
conda create -n test-esutil numpy pip
source activate test-esutil
pip install esutil
python -c 'import esutil'
Of course, if you are using conda you can just do conda install esutil
which is better
does this apt installed python include numpy?
Note this also works, using the ubuntu system python3 rather than conda
python3 -m venv test-esutil
pip3 install numpy
pip3 install esutil
python3 -c 'import esutil'
No, of course not. So most probably the reason is what esutil does not list numpy as its dependency (it is commented out in setup.py?..)
This really breaks things when installing esutil as a requirement for another package - it tries to pull everything including numpy (which my package also depends on), and then install esutil before (or in parallel?..) with numpy, and thus produces broken wheel - that's how I actually encountered it.
Early on in the life of esutil, having numpy as a dependency for pip was a big problem. It often could not do the numpy install. And in certain situations it could not detect existing numpy correctly.
This was like 10 years ago.
So I kept the dependency out of the setup.py to avoid breaking existing setups.
It seems that the numpy pip install is pretty reliable now. I think it is probably safe to put in that dependency.
Would you be able to make a PR?
It does not actually solve the problem completely - as the test for whether numpy is installed happens before setup.py actually installs it as a requirement. Probably it might be moved e.g. into the builder?..
good point. Do you want to take a shot at a PR?
I believe this was fixed by #77.
Hi, I just encountered this issue when installing esutil
from pip
python -m pip install esutil
which installs a precompiled v0.6.10.
After reading this thread, I tried to install the development version instead
python -m pip install git+https://github.com/esheldon/esutil.git
and it solved the issue.
Since 0.6.10 is dated from Jan 8 and #77 was merged on Jan 10, I also believe this has been fixed in the current version. Perhaps a new release on PyPI would be useful.
I'll release 0.6.11 today
released