Skip to content

nb-cli installed via pipx fails when system has Python < 3.1 #204

@afterow

Description

@afterow

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:

  1. Have Python 3.8 installed and set as the default python command in system PATH
  2. Install nb-cli via pipx with a newer Python version:
    pipx install nb-cli --python python3.13
  3. Run nb command:
    nb
  4. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions