[Python] VS Code cannot find discord.py module

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

  1. Stack

    Stack Membro Participativo

    An issue that I've searched and searched for a solution to with no avail. I've installed the discord.py module through the cmd prompt using the command

    py -3 -m pip install -U discord.py


    Running it again gives me the message that the dependencies are already satisfied. I've checked both the pip version and python version in both the command prompt, to see where they are installing, and the VS code terminal, and they both affirm the 3.13.3 version of Python.

    Running:

    > python
    >>> help
    >>> modules


    spits out the list of modules, including discord right between dis and doctest. Running help> discord spits out:

    Help on package discord:

    NAME
    discord

    DESCRIPTION
    Discord API Wrapper
    ~~~~~~~~~~~~~~~~~~~

    A basic wrapper for the Discord API.

    :copyright: (c) 2015-present Rapptz
    :license: MIT, see LICENSE for more details.

    PACKAGE CONTENTS
    (a comprehensive list of all the modules, I've checked)

    SUBMODULES
    async_
    sync

    DATA
    __annotations__ = {'version_info': <class 'discord.VersionInfo'>}
    __copyright__ = 'Copyright 2015-present Rapptz'
    __license__ = 'MIT'
    __title__ = 'discord'
    version_info = VersionInfo(major=2, minor=5, micro=2, releaselevel='fi...

    VERSION
    2.5.2

    AUTHOR
    Rapptz

    FILE
    c:\users\MYUSER\appdata\local\programs\python\python313\lib\site-packages\discord\__init__.py


    Running > pip show discord.py or > pip3 show discord.py both spit out:

    Name: discord.py
    Version: 2.5.2
    Summary: A Python wrapper for the Discord API
    Home-page:
    Author: Rapptz
    Author-email:
    License: The MIT License (MIT)

    Copyright (c) 2015-present Rapptz

    (large portion of legal text ommitted for ease of reading)

    Location: C:\Users\MYUSER\AppData\Local\Programs\Python\Python313\Lib\site-packages
    Requires: aiohttp, audioop-lts
    Required-by:


    I've genuinely tried what I see as everything. But no matter what, any .py file I make underlines in yellow the discord part of the line import discord with the error: Import "discord" could not be resolvedPylance(reportMissingImports). Running the python file through VS code throws the error:

    Traceback (most recent call last):
    File "c:\Users\MYUSER\OneDrive\Documents\FOLDER_NAME\FOLDER_NAME\FILENAME.py", line 1, in <module>
    import discord
    ModuleNotFoundError: No module named 'discord'


    If anyone has any possible advice on how to fix the issue here, that would be greatly greatly appreciated. Thanks in advance!

    EDIT: To add screenshot of IDE I apparently can't embed yet so here

    Continue reading...

Compartilhe esta Página