Jyotirmay
Jyotirmay

Reputation: 554

How do you install external python libraries in VS Code?

I have been using VS Code for a few months for coding in python 3.7.2 for both my school and personal projects. But I am stuck at a stage when I tried to code a discord bot in python. I used pip to install the discord library last night but for some reason when I import discord, it throws an error:

File "c:/Users/Jyotirmay Kumar Jha/VS Code Projects/discord/test.py", line 2, in <module>
    import discord
ModuleNotFoundError: No module named 'discord'

I have installed python in the directory "C:\Python\Python37\python.exe" but I am really not sure if the discord module got installed in that location because that is the python interpreter that VS Code is using.

enter image description here

So, I tried browsing the web to find the actual method to install a module that can be used by VS Code too but they all suggested that I use windows command prompt for it which I had actually done.

What I want to ask is how to get that discord module to work in Visual Studio Code too? And for future, how do I know if a module is installed on my device?

Upvotes: 3

Views: 12313

Answers (1)

they-them
they-them

Reputation: 61

Make sure to use something along the lines of python3 -m pip install discord.py as python3 uses a separate pip version. Looking at https://github.com/Rapptz/discord.py/issues/228, it seems there's also a dead/not real package under the same name that doesn't work.

Upvotes: 2

Related Questions