为什么我的Python代码看不到导入的discord.py模块? [英] Why doesn't my Python code see the imported discord.py module?

查看:169
本文介绍了为什么我的Python代码看不到导入的discord.py模块?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Python制作我的第一个Discord Bot,它在我的台式Windows计算机上完美运行。我还有一台运行Ubuntu的笔记本电脑,但我在Intellij中将存储库克隆到了无法正常工作的地方。因为我使用的Python版本略有不同(3.6.1和3.5.2),所以将其设置为忽略我的 misc.xml 文件,因为它包含一个Project-JDK -名称。我是根据其他项目(3.5.2)自动生成的,在笔记本电脑上手动重新创建的。

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).

在笔记本电脑上,它强调了导入discord 行,并告诉我找不到模块。我已经使用 python3 -m pip install discord 安装了它,然后重新安装告诉我它已经存在。

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.

基于此链接,我也尝试运行 python3 然后 import cmord 在cmd中,没有输出,因此我假设它没有错误。那么,为什么我的Python项目看不到该模块呢?

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?

项目结构: http://imgur.com/a/ewddr

推荐答案

您的想法可能已经使用与您下载discord.py所使用的解释器不同的python解释器。您将需要更改sdk设置。遵循本教程: https:// www.jetbrains.com/help/idea/2017.1/configuring-python-interpreter-for-a-project.html

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


配置Python Python模块的解释器,请按照以下
步骤

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

打开项目结构对话框(例如Ctrl + Shift + Alt + S)。

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

在项目结构对话框中,单击项目
设置下的模块节点。

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

在选定的Python
模块的模块窗格中,单击依赖关系选项卡。

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

单击Module SDK下拉列表
,然后从
先前配置的可用Python解释器的列表中选择所需的Python解释器。

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

如果可用的
解释器列表中缺少所需的解释器,请单击Module SDK字段旁边的新建,从弹出菜单中选择Python
SDK,选择解释器类型(升ocal,remote,
等),然后选择所需的可执行文件。

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.

这篇关于为什么我的Python代码看不到导入的discord.py模块?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆