Skip to content

ant dev example Python runner uses python3 from PATH instead of sys.executable #63

@Nic-dorman

Description

@Nic-dorman

Bug

ant dev example <name> -l python shells out to python3 from the user's PATH rather than sys.executable (the interpreter that's running ant-dev itself). On Ubuntu 24.04 — where PEP 668 makes a system-wide pip install -e ant-dev/ impossible — ant-dev lives in a venv. The venv's python3 has antd installed; the system python3 does not. So unless the user has manually activated the venv, the example fails:

$ ant dev example data -l python
Traceback (most recent call last):
  File "/home/nic/Projects/ant-sdk/antd-py/examples/02_data.py", line 6, in <module>
    from antd import AntdClient
ModuleNotFoundError: No module named 'antd'

Location

ant-dev/src/ant_dev/cmd_example.py:69-71:

# Use 'python' on Windows, 'python3' on Unix
python = "python" if sys.platform == "win32" else "python3"
result = subprocess.run([python, str(script)])

Fix

Use sys.executable — it always points at the interpreter running ant-dev, which by construction has access to the same dependency tree (since ant-dev depends on antd[rest]):

result = subprocess.run([sys.executable, str(script)])

This also removes the Windows special-case.

Environment

  • Ubuntu 24.04.4 LTS in an Incus LXC
  • ant-dev installed via python3 -m venv ~/.venvs/ant-dev && pip install -e antd-py[rest] && pip install -e ant-dev (PEP 668 blocks system-wide install)

Workaround in the meantime: . ~/.venvs/ant-dev/bin/activate before ant dev example ….

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions