[Python] Pylance & Pylint report “could not be resolved” / “no-member” for a valid PyPI...

Discussão em 'Python' iniciado por Stack, Abril 26, 2025.

  1. Stack

    Stack Membro Participativo

    What configuration changes are needed in VSCode (or in my project layout) to make Pylance and Pylint recognize the installed cowsay package and its members? Is there a best practice for structuring local packages alongside third-party libraries so that both analysis engines pick them up correctly?

    I’ve created a Python 3 virtual environment in VSCode (using python -m venv venv at the project root), installed the cowsay library via pip, and selected the interpreter from venv. However, in my source file I see:

    Import "cowsay" could not be resolved PylancereportMissingImports
    Module 'cowsay' has no 'cow' member PylintE1101:no-member


    Code:

    import cowsay
    import sys

    if len(sys.argv) == 2:
    cowsay.cow("Hello there, " + sys.argv[1])


    This happens even though running the script with:

    ./venv/bin/python3.13 packages/say.py carl

    prints the correct output:

    ./venv/bin/python3.13 packages/say.py carl
    _________________
    | Hello there, carl |
    =================
    \
    \
    ^__^
    (oo)\_______
    (__)\ )\/\
    ||----w |
    || ||



    Project structure:

    project-root/
    ├── packages/
    │ └── say.py
    ├── venv/ ← virtual environment


    Confirming VSCode is using the venv/bin/python interrupter [​IMG]

    [​IMG]

    [​IMG]

    Continue reading...

Compartilhe esta Página