[Python] Installing my own single-file Python project

Discussão em 'Python' iniciado por Stack, Junho 3, 2025.

  1. Stack

    Stack Membro Participativo

    I have a rather small package, with only the single __init__.py at the top-level, which I attempt to install with pip-3.11 install --user ..

    Pip duly processes my pyproject.toml, checking all of the dependencies, and ends with these reassuring messages:

    Building wheels for collected packages: mypackage
    Building wheel for mypackage (pyproject.toml) ... done
    Created wheel for mypackage: filename=mypackage-0.1-py3-none-any.whl size=3251 sha256=4a4fbb798d9557c52b4751b545cebcca75501a238092d02d055aea4147680a2f
    Stored in directory: /tmp/pip-ephem-wheel-cache-nm8w_8n1/wheels/b7/e9/c7/84dde047e428daca2ad6421e22f0c84327b33be5ac57e2c8e2
    Successfully built mypackage
    Installing collected packages: mypackage
    Successfully installed mypackage-0.1


    After this, I see my __init__.py copied into the newly-created build/lib/ subdirectory. The ~/.local/lib/python3.11/site-packages/mypackage-0.1.dist-info bnysms.egg-info is also created, with various files describing the package in it.

    But there is no ~/.local/lib/python3.11/site-packages/mypackage/ itself -- and my package is not, in fact, installed. Attempting to run python3.11 -m mypackage responds with No module named mypackage.

    The pip-3.11 freeze | grep mypackage lists it without version: mypackage @ file:///home/me/mypackage.

    I tried adding an explicit section:

    [tool.setuptools]
    py-modules = ["__init__"]


    but that didn't change anything... What am I missing?

    Continue reading...

Compartilhe esta Página