Why doesn't my Python code see the imported di

2019-09-14 17:26发布

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

1条回答
混吃等死
2楼-- · 2019-09-14 18:04

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 (e.g. 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.

查看更多
登录 后发表回答