Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fail to install using Poetry #30

Open
fgmacedo opened this issue Sep 3, 2021 · 7 comments
Open

Fail to install using Poetry #30

fgmacedo opened this issue Sep 3, 2021 · 7 comments

Comments

@fgmacedo
Copy link

fgmacedo commented Sep 3, 2021

I'm trying to install this lib using poetry.

My pyproject.yml has two direct dependencies:

numpy = "1.18.4"
lap = "0.4.0"

But since lap also needs numpy, there's no way to poetry to resolve dependencies without the lap mentioning that numpy is a install dependency.

I've found that this custom setup instructions is probably the issue, not compatible with the way poetry tries to install:

lap/setup.py

Lines 204 to 222 in ece5ee9

if len(sys.argv) == 1 or (
len(sys.argv) >= 2 and ('--help' in sys.argv[1:] or
sys.argv[1] in ('--help-commands',
'egg_info',
'--version',
'clean'))):
try:
from setuptools import setup
except ImportError:
from distutils.core import setup
else:
numpy_status = get_numpy_status()
if numpy_status['up_to_date'] is False:
if numpy_status['version']:
raise ImportError('Installed numpy is too old, '
'please "pip install -U numpy".')
else:
raise ImportError('lap requires numpy, '
'please "pip install numpy".')

Error:

❯ poetry add "lap[alldeps]"
Using version ^0.4.0 for lap

Updating dependencies
Resolving dependencies... (0.5s)


Package operations: 5 installs, 0 updates, 0 removals

  - Installing lap (0.4.0)

[EnvCommandError]
Command ['/home/fernando/.cache/pypoetry/virtualenvs/sM4e1v81-py3.7/bin/pip', 'install', '--no-deps', 'lap==0.4.0'] errored with the following return code 1, and output:
Collecting lap==0.4.0
  Using cached https://files.pythonhosted.org/packages/bf/64/d9fb6a75b15e783952b2fec6970f033462e67db32dc43dfbb404c14e91c2/lap-0.4.0.tar.gz
Installing collected packages: lap
  Running setup.py install for lap: started
    Running setup.py install for lap: finished with status 'error'
    ERROR: Command errored out with exit status 1:
     command: /home/fernando/.cache/pypoetry/virtualenvs/sM4e1v81-py3.7/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-h0wwep35/lap/setup.py'"'"'; __file__='"'"'/tmp/pip-install-h0wwep35/lap/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-fls2s3js/install-record.txt --single-version-externally-managed --compile --install-headers /home/fernando/.cache/pypoetry/virtualenvs/sM4e1v81-py3.7/include/site/python3.7/lap
         cwd: /tmp/pip-install-h0wwep35/lap/
    Complete output (12 lines):
    Partial import of lap during the build process.
    Traceback (most recent call last):
      File "/tmp/pip-install-h0wwep35/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-h0wwep35/lap/setup.py", line 236, in <module>
        setup_package()
      File "/tmp/pip-install-h0wwep35/lap/setup.py", line 220, in setup_package
        raise ImportError('lap requires numpy, '
    ImportError: lap requires numpy, please "pip install numpy".
    ----------------------------------------
ERROR: Command errored out with exit status 1: /home/fernando/.cache/pypoetry/virtualenvs/sM4e1v81-py3.7/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-h0wwep35/lap/setup.py'"'"'; __file__='"'"'/tmp/pip-install-h0wwep35/lap/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-fls2s3js/install-record.txt --single-version-externally-managed --compile --install-headers /home/fernando/.cache/pypoetry/virtualenvs/sM4e1v81-py3.7/include/site/python3.7/lap Check the logs for full command output.
@gatagat
Copy link
Owner

gatagat commented Sep 7, 2021

First, thanks for reporting.

I don't know much about poetry yet, but I was thinking about giving it a try. Unfortunately I will not have enough time to devote to this soon. In case you would, I am happy to discuss the details.

@fgmacedo
Copy link
Author

fgmacedo commented Sep 7, 2021

Thanks @gatagat. I think that a quickly approach is to declare cython and numpy as explicit requirements using install_requires, I've forked the repo to not be blocked by this and it indeed solved the install issue. If you're ok with this I'll be glad to send a PR.

Let me know if you have any other suggestion.

Best regards!

@lig
Copy link

lig commented Aug 31, 2022

@fgmacedo do it :)

@Almorisson
Copy link

Almorisson commented Sep 2, 2022

For people who are struggling to install lap with docker, you can try to use the other fork of the same project called lap05.

You can make a search on pypi for the version that most sweet to you.
In your pyproject.toml:

lap05 = "0.5.1"
numpy = "1.23.2" # You have to add this line because `numpy` is a dependancy of lap

Just make sure, you also install the python3-dev lib in the section of your docker file where you install system deps.

Example:

# install system dependencies
RUN apt-get update && \
    apt-get install -y build-essential && \
    apt-get install -y python3-dev && \
    apt-get install -y telnet netcat && \
    apt-get install -y --no-install-recommends gcc && \
    apt-get install -y locales wkhtmltopdf jq && \
    apt-get install -y curl

@lig
Copy link

lig commented Sep 2, 2022

@Almorisson if numpy is a dependency it should be defined as such in lap05, isn't it?

#41 solved the installation problem for me without the need to add numpy explicitly.

Unfortunately, there is no word from @gatagat regarding the PR.

@AlanBlanchet
Copy link

For anyone coming accross this. You can use lapx instead which will resolve to lap when importing.
It worked for me when lauching the test scripts of mmdet

pip install lapx
import lap

@itmerk
Copy link

itmerk commented Nov 9, 2024

Its working for lap error fixing. Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants