简体   繁体   中英

Can't import external packages with python

Title. It just doesn't recognize it. For example, I'm trying to make a discord bot with discord.py. I do the pip install thingy, and it just spits this out when I try to run my file:

Traceback (most recent call last):
    File "C:\Users\Pixel\Desktop\Discord bot\bot.py". line 1, in <module>
        import discord
ModuleNotFoundError: No module named 'discord' 

It does exist, I checked: (C:\Python38\lib\site-packages\discord)
Am I doing something wrong here or am I just stupid? Thanks!

There are many possible reasons for this error. You might have multiple versions of Python running on your machine, so you could have installed the module in a version of Python that your code is not using.

Make sure you're using the write version of Python as your interpreter.

You could also try installing the module directly in whatever venv you're using by typing this command into the terminal in the same folder python3.9 -m pip install discord . Replace python3.9 with whatever version of Python you're using.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM