简体   繁体   中英

Why doesn't my Python code see the imported discord.py module?

I'm trying to make my first Discord Bot using Python, and it works perfectly on my desktop Windows computer. I also have a laptop running Ubuntu that I cloned the repository to in Intellij that isn't working correctly. Because I'm using slightly different Python versions (3.6.1 vs 3.5.2), I set it up to ignore my misc.xml file since it includes a Project-JDK-Name. I manually recreated it on my laptop based on an autogenerated one from another project (3.5.2).

On the laptop, it underlines the import discord line and tells me it cannot find the module. I have installed it using python3 -m pip install discord and reinstallation tells me it already exists.

Based on this link , I also tried running python3 then import discord in cmd, and got no output, so I'm assuming it didn't have an error. Why, then, does my Python project not see the module?

Project Structure: http://imgur.com/a/ewddr

Your ide might have been using a different python interpreter than the one you download discord.py to. You will need to change the sdk settings. Follow this tutorial: https://www.jetbrains.com/help/idea/2017.1/configuring-python-interpreter-for-a-project.html

To configure Python interpreter for a Python module, follow these steps

Open the Project Structure dialog (eg Ctrl+Shift+Alt+S).

In the Project Structure dialog box, click Modules node under the Project Settings.

In the Module pane of the selected Python module, click the Dependencies tab.

Click Module SDK drop-down list, and select the desired Python interpreter from the list of the previously configured available Python interpreters.

If the interpreter you need is missing in the list of available interpreters, click New next to the Module SDK field, choose Python SDK from the pop-up menu, choose interpreter type (local, remote, etc.) and then select the desired executable.

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