skip to Main Content

I’m trying to make a discord bot, and I keep getting this error:
Import "discord" could not be resolved Pylance(reportMissingImports)

I used this to install the package:
py -3 -m pip install -U discord.py

I am using the cmd on Visual Studio Code for this. Can anyone help?

2

Answers


  1. Try these steps:

    1. Run VS Code as administrator > Navigate to your project path in the Terminal (CMD) in VS Code > Then Run the command py -3 -m pip install -U discord.py

    2. If Step 1 doesn’t work, Open the Command Prompt as administrator from the Windows System (Not in VS Code) > Navigate to the project path & Run that same command.

    • And then restart the VS Code and check!

    Note: Make Sure you have installed the latest Python 3.x version

    Login or Signup to reply.
  2. First, you should use the following command to install the discord package.

    pip install discord
    

    Secondly, maybe there are multiple python environments on your machine, please use Ctrl+Shift+P to open the command palette, then search and select Python:Select Interpreter, and select the correct interpreter.

    enter image description here

    enter image description here

    There are two ways to be right here

    • Select the interpreter environment where you successfully installed the discord package earlier
    • Choose an interpreter environment you want to use, then create a new terminal to activate the environment, and install the discord package for your new environment.
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search