[Python] UV Workspaces Module Not Found

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

  1. Stack

    Stack Membro Participativo

    This is my directory structure:

    myProject
    ├── pyproject.toml
    ├── apps
    │ └── myApp
    │ ├── pyproject.toml
    │ └── main.py
    └── lib
    └── myLib
    ├── pyproject.toml
    ├── main.py
    └── __init__.py


    In the top level pyproject.toml I have the following:

    [project]
    name = "myProject"
    version = "0.1.0"
    description = "description"
    readme = "README.md"
    requires-python = ">=3.13"

    # Added these here as I want to ensure that python libraries across
    # projects and internal libs are updated together [ living at the
    # head ]
    dependencies = [
    "myApp @ file:///${PROJECT_ROOT}/apps/myApp",
    "myLib @ file:///${PROJECT_ROOT}/lib/myLib"
    ]

    # Ensuring these come from the workspace i.e. the repo itself
    [tool.uv.sources]
    myLib = { workspace = true }
    myApp = { workspace = true }

    [tool.uv.workspace]
    members = [
    "apps/myApp",
    "lib/myLib",
    ]

    [build-system]
    requires = ["setuptools", "wheel"]
    build-backend = "setuptools.build_meta"

    Now in my `main.py` in `myLib` I have a very simple script:
    ```python
    def greet():
    return "Hello!"


    And in main.py in myApp I intend to use it:

    from myLib.main import greet

    print(greet())


    To achieve this I run the following from root:

    uv pip install .
    uv python run apps/myApp/main.py


    But I constantly run into:

    File "/Users/dummy/myProject/apps/myApp/main.py", line 1, in <module>
    from myLib.main import greet
    ModuleNotFoundError: No module named 'myLib'


    What step am I missing here?

    Continue reading...

Compartilhe esta Página