[Python] how to do install my custom package in editable mode, with uv

Discussão em 'Python' iniciado por Stack, Fevereiro 18, 2025.

  1. Stack

    Stack Membro Participativo

    My colleagues told me to try 'uv'. It is true that it is handy, but I quickly faced a huge problem: I can't install my custom sources.

    Usually, my projects' structures look like this:

    my_project/
    │── src/
    │ ├── backend/
    │ │ ├── __init__.py
    │ │ ├── some_module.py
    │── scripts/
    │ ├── my_script.py
    │── pyproject.toml (or setup.py)
    │── other_project_files...


    What I do with venv is I pip install -e . so that I install my 'src' package and I can use it in my scripts.

    Now I have been trying to pip install -e . or uv run pip install -e . but it just does nothing. When I try to execute my script which uses src it does not find src.

    What am I doing wrong ?

    Edit: adding details

    [​IMG]

    I run

    uv init


    then I run

    uv run pip install -e .


    then

    uv run scripts/importmylist.py


    It gives:

    Traceback (most recent call last):
    File "...\test_repo\scripts\importmylist.py", line 1, in <module>
    from src.utils import my_list
    ModuleNotFoundError: No module named 'src'


    Content of pyproject:

    [project]
    name = "test-repo"
    version = "0.1.0"
    description = "Add your description here"
    readme = "README.md"
    requires-python = ">=3.12"
    dependencies = []

    Continue reading...

Compartilhe esta Página