esutil icon indicating copy to clipboard operation
esutil copied to clipboard

Installation from pip on a clean system is broken

Open karpov-sv opened this issue 2 years ago • 11 comments

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'

karpov-sv avatar Jun 02 '22 09:06 karpov-sv

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

esheldon avatar Jun 02 '22 13:06 esheldon

does this apt installed python include numpy?

esheldon avatar Jun 02 '22 13:06 esheldon

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'

esheldon avatar Jun 02 '22 13:06 esheldon

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.

karpov-sv avatar Jun 02 '22 13:06 karpov-sv

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?

esheldon avatar Jun 02 '22 13:06 esheldon

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?..

karpov-sv avatar Jun 02 '22 14:06 karpov-sv

good point. Do you want to take a shot at a PR?

esheldon avatar Jun 02 '22 15:06 esheldon

I believe this was fixed by #77.

jobovy avatar Aug 23 '23 00:08 jobovy

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.

aboucaud avatar Sep 13 '23 10:09 aboucaud

I'll release 0.6.11 today

esheldon avatar Sep 13 '23 12:09 esheldon

released

esheldon avatar Sep 13 '23 13:09 esheldon