Home > Blockchain >  Import "discord" could not be resolved error
Import "discord" could not be resolved error

Time:08-16

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?

CodePudding user response:

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 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.
  • Related