nb-cli installed via pipx fails when system has Python < 3.1
Describe the bug
When nb-cli is installed via pipx with Python 3.13, running nb command fails with PythonInterpreterError: Python 3.8 is not supported if the system's default python command points to Python 3.8.
To Reproduce
Steps to reproduce the behavior:
- Have Python 3.8 installed and set as the default
python command in system PATH
- Install
nb-cli via pipx with a newer Python version:
pipx install nb-cli --python python3.13
- Run
nb command:
- See error:
nb_cli.exceptions.PythonInterpreterError: Python 3.8 is not supported.
Expected behavior
nb-cli should prioritize using its own Python interpreter (the one it's running in, i.e., sys.executable) when the version meets the requirement (>= 3.10), rather than always searching for python in the system PATH.
Current behavior
From meta.py#L65-L89:
@cache(ttl=None)
async def _get_env_python() -> str:
python_to_try = WINDOWS_DEFAULT_PYTHON if WINDOWS else DEFAULT_PYTHON
# WINDOWS_DEFAULT_PYTHON = ("python",)
for python in python_to_try:
proc = await create_process_shell(f"{python} -W ignore -c ...")
Although the NoneBot project has now removed support for Python 3.9
but On Windows, it only tries the python command from system PATH, which may point to an unsupported Python version (< 3.10), even though nb-cli itself is running in a Python 3.13 virtual environment.
Environment
- OS: Windows
- Python version (nb-cli venv): 3.13.5
- Python version (system default): 3.8.x
- nb-cli version: 1.7.4
- Installation method: pipx
Suggested fix
none
nb-cli installed via pipx fails when system has Python < 3.1
Describe the bug
When
nb-cliis installed viapipxwith Python 3.13, runningnbcommand fails withPythonInterpreterError: Python 3.8 is not supportedif the system's defaultpythoncommand points to Python 3.8.To Reproduce
Steps to reproduce the behavior:
pythoncommand in system PATHnb-clivia pipx with a newer Python version:nbcommand:Expected behavior
nb-clishould prioritize using its own Python interpreter (the one it's running in, i.e.,sys.executable) when the version meets the requirement (>= 3.10), rather than always searching forpythonin the system PATH.Current behavior
From meta.py#L65-L89:
Although the NoneBot project has now removed support for Python 3.9
but On Windows, it only tries the
pythoncommand from system PATH, which may point to an unsupported Python version (< 3.10), even thoughnb-cliitself is running in a Python 3.13 virtual environment.Environment
Suggested fix
none