ModuleNotFoundError:没有名为“discord”的模块(详细信息如下)

2024-06-06 23:49:51 发布

您现在位置:Python中文网/ 问答频道 /正文

因此,我尝试安装discord API包装器来解决discord问题,我不确定它是不是走错了路或是什么。我尝试导入的每件事都会导致上面的错误。在

我如何验证安装了pip,然后安装了discord:

moro@Falco123:~$ sudo apt-get install  python3-pip
Reading package lists... Done
Building dependency tree      
Reading state information... Done
python3-pip is already the newest version (9.0.1-2).
0 upgraded, 0 newly installed, 0 to remove and 222 not upgraded.
moro@Falco123:~$ pip3 install -U discord.py
Collecting discord.py
Collecting aiohttp<1.1.0,>=1.0.0 (from discord.py)
  Using cached aiohttp-1.0.5-cp35-cp35m-manylinux1_x86_64.whl
Collecting websockets<4.0,>=3.1 (from discord.py)
  Using cached websockets-3.3-py33.py34.py35.py36-none-any.whl
Collecting chardet (from aiohttp<1.1.0,>=1.0.0->discord.py)
  Using cached chardet-3.0.4-py2.py3-none-any.whl
Collecting async-timeout (from aiohttp<1.1.0,>=1.0.0->discord.py)
  Using cached async_timeout-1.2.1-py3-none-any.whl
Collecting multidict>=2.0 (from aiohttp<1.1.0,>=1.0.0->discord.py)
  Using cached multidict-3.1.3-cp35-cp35m-manylinux1_x86_64.whl
Installing collected packages: chardet, async-timeout, multidict, aiohttp, 
websockets, discord.py
Successfully installed aiohttp-1.0.5 async-timeout-1.2.1 chardet-3.0.4 
discord.py-0.16.8 multidict-3.1.3 websockets-3.3
moro@Falco123:~$ python3.6
Python 3.6.2 (default, Aug 16 2017, 16:00:27)
[GCC 6.3.0 20170406] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import discord
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'discord'
>>> exit()

我在python官方文档页面上也尝试过这种方法,但是没有:

^{pr2}$

主要的问题是我想安装discord模块以在python脚本中使用。我还使用默认的ubuntupython3.5和我安装的python3.6中的“help('modules')”检查python3模块列表中是否有不和谐。它没有被列出来。请随时请求其他命令或信息

编辑:

moro@Falco123:/usr/bin$ pip3 -V
pip 9.0.1 from /usr/lib/python3/dist-packages (python 3.5)
moro@Falco123:/usr/bin$

编辑:

moro@Falco123:~$ python3.6 -m pip install discord.py
/usr/local/bin/python3.6: No module named pip
moro@Falco123:~$

编辑:

我从官方网站下载python3.6.2安装python,然后用以下命令提取、编译并安装:

cd Downloads/
cd Python-3.6.2/
./configure
sudo make
sudo make install

编辑:当我编译python时,我没有用SSL编译它。对于未来有此问题的人,请参见此处:https://github.com/Rapptz/discord.py/issues/331 另外,要添加SSL,请看他开始安装SSL的大约一半时间:https://www.youtube.com/watch?v=X4nPFZCf-wM


Tags: installpipfrompyaiohttpwebsocketspython3using