Home > Net >  I tried to add Python to VSCode, but it won't work
I tried to add Python to VSCode, but it won't work

Time:10-16

I opened command prompt (I'm on Windows) and I typed:

'''none pip3 install discord '''

Then it said it installed discord, and I was ready to go! (I already had Python 3.9.7 installed) Then when I opened VSCode up and typed: import discord I got this error message:

"discord" is not accessedPylance

Import "discord" could not be resolvedPylancereportMissingImports

What does this mean, and how can I fix it? I was really looking forward to coding the bot, but don't know how, now that this is messed up.

CodePudding user response:

check in the bottom left corner of the VS Code window for which version of Python is it using. This issue usually occurs for me when I’m working in a virtual environment but VS Code is pointing to my global Python installation.

CodePudding user response:

You can change the Python Interpreter in VSCODE to solve this issue.


  1. Open settings in VSCODE by pressing Ctrl Shift P. Make sure your .py file is open while doing this step.
  1. Search there Python: Select Interpreter and choose the right version.

  2. Reload VSCODE and see if it works!

CodePudding user response:

Open an integrated Terminal in VS Code,

  1. run python --version, it should be python3.9.7 which is selected as python interpreter and shown in status bar.

  2. run pip show discord to check if its location is \..\python3.9.3\lib\site-packages. If not, reinstall it.

  • Related