0

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 enter image description here

enter image description here

enter image description here

3
  • From my experience, it should be configurable in the settings.json. Try this guide: micropython-stubs.readthedocs.io/en/main/22_vscode.html Commented Apr 26 at 17:09
  • For Pylance, have you tried adding your modules to python.analysis.extraPaths? See github.com/microsoft/pylance-release/blob/main/docs/settings/… Commented Apr 27 at 2:28
  • For Pylint, haven't used it in years, but there's probably a similar configuration to tell it where to custom modules. (You also have to understand that they are two separate linters, not dependent on each other, so need their own configurations) Commented Apr 27 at 2:29

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.