gatagat / lap

Linear Assignment Problem solver (LAPJV/LAPMOD).
BSD 2-Clause "Simplified" License
211 stars 66 forks source link

Problem installing lap if numpy not already installed #38

Open shachargluska opened 2 years ago

shachargluska commented 2 years ago

Hi, looks like setup.py raises an ImportError if lap can't find numpy.

Collecting lap
  Using cached lap-0.4.0.tar.gz (1.5 MB)
Building wheels for collected packages: lap
  Building wheel for lap (setup.py) ... error
  ERROR: Command errored out with exit status 1:
   command: /root/test/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-j7vxs02x/lap/setup.py'"'"'; __file__='"'"'/tmp/pip-install-j7vxs02x/lap/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-mo5fc8iw
       cwd: /tmp/pip-install-j7vxs02x/lap/
  Complete output (12 lines):
  Partial import of lap during the build process.
  Traceback (most recent call last):
    File "/tmp/pip-install-j7vxs02x/lap/setup.py", line 127, in get_numpy_status
      import numpy
  ModuleNotFoundError: No module named 'numpy'
  Traceback (most recent call last):
    File "<string>", line 1, in <module>
    File "/tmp/pip-install-j7vxs02x/lap/setup.py", line 236, in <module>
      setup_package()
    File "/tmp/pip-install-j7vxs02x/lap/setup.py", line 220, in setup_package
      raise ImportError('lap requires numpy, '
  ImportError: lap requires numpy, please "pip install numpy".
  ----------------------------------------
  ERROR: Failed building wheel for lap

pip install lap[alldeps] still throws this error, but succeeds with pip 20.0.2. For pip 22.0.3, this fails again:

Collecting numpy>=1.10.1
  Using cached numpy-1.22.2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (16.8 MB)
Using legacy 'setup.py install' for lap, since package 'wheel' is not installed.
Installing collected packages: lap, numpy
  Running setup.py install for lap ... error
  error: subprocess-exited-with-error

  × Running setup.py install for lap did not run successfully.
  │ exit code: 1
  ╰─> [13 lines of output]
      Partial import of lap during the build process.
      Traceback (most recent call last):
        File "/tmp/pip-install-oqm50v48/lap_691c504a80774ff7a3048730fdd528c8/setup.py", line 127, in get_numpy_status
          import numpy
      ModuleNotFoundError: No module named 'numpy'
      Traceback (most recent call last):
        File "<string>", line 2, in <module>
        File "<pip-setuptools-caller>", line 34, in <module>
        File "/tmp/pip-install-oqm50v48/lap_691c504a80774ff7a3048730fdd528c8/setup.py", line 236, in <module>
          setup_package()
        File "/tmp/pip-install-oqm50v48/lap_691c504a80774ff7a3048730fdd528c8/setup.py", line 220, in setup_package
          raise ImportError('lap requires numpy, '
      ImportError: lap requires numpy, please "pip install numpy".
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: legacy-install-failure

× Encountered error while trying to install package.
╰─> lap

pip install numpy lap also doesn't solve this, because lap is (possible) setup before numpy.

I think checking for the import in setup.py is problematic, since setuptools.setup isn't called yet. I think the import check should be moved to the package itself.

Currently this can be worked around by using 2 separate pip calls. This makes it harder to include lap in a requirements.txt file.

gatagat commented 2 years ago

Hi @shachargluska,

thanks for reporting this, I am aware of this being suboptimal and have it on the todo list to be patched. My plan is to get rid of the current setup.py altogether, ideally going for poetry. Lately I don't have much spare time on my hands, so this might take a while.

If you had time, experience and will to help with that, let me know.

Cheers, Tomas

rnixx commented 1 year ago

My plan is to get rid of the current setup.py altogether

Why not just passing install_requires kw argument to setup() call?

Mr-LiuDC commented 1 year ago

Same issue here.

Environment;

Ubuntu 20.04.4 LTS  64 Bit
Python version  3.7.15
pip version  22.2.2
gcc, g++ version 9.4.0

Here is my requirements.txt

Flask==2.2.2
h5py==2.10.0
keras==2.2.4
paddlex==2.1.0
filelock==3.8.0
pyntcloud==0.1.2
pythreejs==2.1.1
protobuf==3.20.0
tensorflow==1.13.1
fuzzywuzzy==0.18.0
paddlepaddle==2.3.2
scikit-image==0.16.2
opencv-python==4.1.0.25
image-classifiers==1.0.0

Error details:

  Running setup.py install for lap ... error
  error: subprocess-exited-with-error

  × Running setup.py install for lap did not run successfully.
  │ exit code: 1
  ╰─> [13 lines of output]
      Partial import of lap during the build process.
      Traceback (most recent call last):
        File "/tmp/pip-install-ojp61hph/lap_766c0d88933341398e3143ad59c12026/setup.py", line 127, in get_numpy_status
          import numpy
      ModuleNotFoundError: No module named 'numpy'
      Traceback (most recent call last):
        File "<string>", line 36, in <module>
        File "<pip-setuptools-caller>", line 34, in <module>
        File "/tmp/pip-install-ojp61hph/lap_766c0d88933341398e3143ad59c12026/setup.py", line 236, in <module>
          setup_package()
        File "/tmp/pip-install-ojp61hph/lap_766c0d88933341398e3143ad59c12026/setup.py", line 220, in setup_package
          raise ImportError('lap requires numpy, '
      ImportError: lap requires numpy, please "pip install numpy".
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: legacy-install-failure

× Encountered error while trying to install package.
╰─> lap

note: This is an issue with the package mentioned above, not pip.
hint: See above for output from the failure.
xxaier commented 1 year ago

same error

mp075496706 commented 1 year ago

Hi, looks like setup.py raises an ImportError if lap can't find numpy.

Collecting lap
  Using cached lap-0.4.0.tar.gz (1.5 MB)
Building wheels for collected packages: lap
  Building wheel for lap (setup.py) ... error
  ERROR: Command errored out with exit status 1:
   command: /root/test/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-j7vxs02x/lap/setup.py'"'"'; __file__='"'"'/tmp/pip-install-j7vxs02x/lap/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-mo5fc8iw
       cwd: /tmp/pip-install-j7vxs02x/lap/
  Complete output (12 lines):
  Partial import of lap during the build process.
  Traceback (most recent call last):
    File "/tmp/pip-install-j7vxs02x/lap/setup.py", line 127, in get_numpy_status
      import numpy
  ModuleNotFoundError: No module named 'numpy'
  Traceback (most recent call last):
    File "<string>", line 1, in <module>
    File "/tmp/pip-install-j7vxs02x/lap/setup.py", line 236, in <module>
      setup_package()
    File "/tmp/pip-install-j7vxs02x/lap/setup.py", line 220, in setup_package
      raise ImportError('lap requires numpy, '
  ImportError: lap requires numpy, please "pip install numpy".
  ----------------------------------------
  ERROR: Failed building wheel for lap

pip install lap[alldeps] still throws this error, but succeeds with pip 20.0.2. For pip 22.0.3, this fails again:

Collecting numpy>=1.10.1
  Using cached numpy-1.22.2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (16.8 MB)
Using legacy 'setup.py install' for lap, since package 'wheel' is not installed.
Installing collected packages: lap, numpy
  Running setup.py install for lap ... error
  error: subprocess-exited-with-error

  × Running setup.py install for lap did not run successfully.
  │ exit code: 1
  ╰─> [13 lines of output]
      Partial import of lap during the build process.
      Traceback (most recent call last):
        File "/tmp/pip-install-oqm50v48/lap_691c504a80774ff7a3048730fdd528c8/setup.py", line 127, in get_numpy_status
          import numpy
      ModuleNotFoundError: No module named 'numpy'
      Traceback (most recent call last):
        File "<string>", line 2, in <module>
        File "<pip-setuptools-caller>", line 34, in <module>
        File "/tmp/pip-install-oqm50v48/lap_691c504a80774ff7a3048730fdd528c8/setup.py", line 236, in <module>
          setup_package()
        File "/tmp/pip-install-oqm50v48/lap_691c504a80774ff7a3048730fdd528c8/setup.py", line 220, in setup_package
          raise ImportError('lap requires numpy, '
      ImportError: lap requires numpy, please "pip install numpy".
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: legacy-install-failure

× Encountered error while trying to install package.
╰─> lap

pip install numpy lap also doesn't solve this, because lap is (possible) setup before numpy.

I think checking for the import in setup.py is problematic, since setuptools.setup isn't called yet. I think the import check should be moved to the package itself.

Currently this can be worked around by using 2 separate pip calls. This makes it harder to include lap in a requirements.txt file.

Yes, I successfully installed the LAP library when using version 22.0.3 of PIP. So, for now, you can use this version of pip for installation.

thiagodaedalus commented 1 year ago

I am also having this issue.

izagood commented 1 year ago

same error

izagood commented 1 year ago

I think the error probably depends on the pip version. (python 3.9.10)

I had a error in pip 23.1.2 version

but pip 21.1.1 version successfully installed

ukersn commented 1 year ago

I think the error probably depends on the pip version. (python 3.9.10)

I had a error in pip 23.1.2 version

but pip 21.1.1 version successfully installed

Thank you. I've been searching online for a long time but I can't find a solution. Your method is actually useful

Penguido commented 1 year ago

Inspired by mp075496706 and izagood, I solved the problem with the following lines of command.

pip install --upgrade pip==22.0.3 # version 23.1.x of pip won't work and the --upgrade option uninstalls the current version to avoid conflicts, so you can't omit it.
pip install numpy
pip install lap
ottokruse commented 10 months ago

I'm running into the same error when installing with https://github.com/mitsuhiko/rye instead of pip

There seems to be no work around with rye because even if I install numpy first, installing lap fails.

rye add numpy
rye sync
rye run python -c 'import numpy; print(numpy.__version__)' # prints 1.26.1 for me
rye add lap
rye sync # fails with ImportError: lap requires numpy, please "pip install numpy".
JorgeRuizITCL commented 9 months ago

Same error with poetry 1.6.1