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

[python-package] “python_requires” should be set with “>=3.5”, as lightgbm 3.3.2 is not compatible with all Python versions. #5004

Closed
PyVCEchecker opened this issue Feb 14, 2022 · 2 comments · Fixed by #5006

Comments

@PyVCEchecker
Copy link
Contributor

Description

Currently, the keyword argument python_requires of setup() is not set, and thus it is assumed that this distribution is compatible with all Python versions.
However, I found it is not compatible with Python 2. My local Python version is 2.7, and I encounter the following error when executing “pip install lightgbm”

Collecting lightgbm
  Downloading lightgbm-3.3.2.tar.gz (1.5 MB)
     |████████████████████████████████| 1.5 MB 233 kB/s 
    ERROR: Command errored out with exit status 1:
     command: /usr/local/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-O0hSCR/lightgbm/setup.py'"'"'; __file__='"'"'/tmp/pip-install-O0hSCR/lightgbm/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-TZ3SVN
         cwd: /tmp/pip-install-O0hSCR/lightgbm/
    Complete output (6 lines):
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-install-O0hSCR/lightgbm/setup.py", line 38
        def find_lib() -> List[str]:
                       ^
    SyntaxError: invalid syntax
    ----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

I noticed that setup.py used the syntax feature Type Hints. The feature is only compatible with Python 3, resulting in installation failure of lightgbm in Python 2.7.

Way to fix:
modify setup() in setup.py, add python_requires keyword argument:

setup(…
     python_requires=">=3.5"
     …)

Thanks for your attention.
Best regrads,
PyVCEchecker

@jameslamb
Copy link
Collaborator

Thanks very much for using LightGBM and for the report, @PyVCEchecker !

We have historically resisted including a floor with python_requires, but I agree that in this case it would take significant effort to get the package working on Python 2.7, and from maintainers' perspective here lightgbm does not support Python 2 (as of #3581).

I'd support a pull request that adds `python_requires='>=3.5'. Would you like to submit one?

@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity since it was closed.
To start a new related discussion, open a new issue at https://github.com/microsoft/LightGBM/issues
including a reference to this.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 16, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants