[Python] How do I install python packages with poetry?

Discussão em 'Python' iniciado por Stack, Janeiro 29, 2025.

  1. Stack

    Stack Membro Participativo

    I am migrating projects to poetry, but I have encountered a problem.

    For example, this is a simple project, not many modules needed. I installed poetry, used poetry add to add the few packages that were required, and then ran poetry install, but it seems like its not installing pandas in my venv.

    My pyproject.toml looks like this:

    [tool.poetry]
    name = "***"
    version = "0.1.0"
    description = ""
    authors = ["***"]

    [tool.poetry.dependencies]
    python = "^3.9"
    pandas = "^1.2.2"
    numpy = "^1.20.1"

    [tool.poetry.dev-dependencies]

    [build-system]
    requires = ["poetry-core>=1.0.0"]
    build-backend = "poetry.core.masonry.api"


    Then I run:

    PS C:\****> poetry install
    Installing dependencies from lock file

    No dependencies to install or update


    However, when I run main.py (which uses pandas), it says there is no module named pandas:

    PS C:\***> python main.py
    Traceback (most recent call last):
    File "C:\***\main.py", line 1, in <module>
    from output import QuestionnaireWrangler, PaymentProbabilityIndex
    File "C:\***\output.py", line 1, in <module>
    import pandas as pd
    ModuleNotFoundError: No module named 'pandas'


    Am I missing some piece of the puzzle here?

    Continue reading...

Compartilhe esta Página