dolfies / discord.py-self

A fork of the popular discord.py for user accounts.
https://discordpy-self.rtfd.io/en/latest/
MIT License
684 stars 162 forks source link

No module named 'discord.ext' #192

Closed tanner02 closed 2 years ago

tanner02 commented 2 years ago

Summary

Doesn't find discord.ext module

Reproduction Steps

import discord from discord.ext import commands, tasks

Code

Traceback (most recent call last):
File "/app/selfbot.py", line 2, in <module>
from discord.ext import commands, tasks
ModuleNotFoundError: No module named 'discord.ext'

Expected Results

find the module

Actual Results

not finding the module for some reason

System Information

Checklist

Additional Information

No response

dolfies commented 2 years ago

Please don't use v1.10-alpha. Try installing from the rebase branch (v2.0), that fixes the issue.

tanner02 commented 2 years ago

The problem still persists on discord.py-self-2.0.0a1

It's also a bit different on my local machine:

from discord.ext import commands, tasks
ImportError: cannot import name 'commands' from 'discord.ext' (unknown location)
dolfies commented 2 years ago

I'll take another look.

rayzchen commented 2 years ago

Issue still exists for me as well

rayzchen commented 2 years ago

There is no __init__.py file in discord.ext folder so how is it imported? I don't have discord.py installed at the same time, because it gives me more errors about no AutoShardedBot.

UkaUkaa commented 2 years ago

Same problem. Updated the rebase branch. Before changes #16ad1a1 worked.

UkaUkaa commented 2 years ago

Through trial and error, I found the last working commit on this issue #6420dfd Everyone after this commit has this error

dolfies commented 2 years ago

Interesting.

dolfies commented 2 years ago

There is no __init__.py file in discord.ext folder so how is it imported? I don't have discord.py installed at the same time, because it gives me more errors about no AutoShardedBot.

AutoShardedBot doesn't exist because users do not shard.

rayzchen commented 2 years ago

I installed the rebase branch using pip install git+https://github.com/dolfies/discord.py-self.git@rebase. This is the discord package directory:

.../site-packages/discord$ ls --color
abc.py               emoji.py         mentions.py       role.py
activity.py          enums.py         message.py        settings.py
appinfo.py           errors.py        mixins.py         stage_instance.py
asset.py             file.py          object.py         state.py
audit_logs.py        flags.py         oggparse.py       sticker.py
backoff.py           gateway.py       opus.py           team.py
bin                  guild_folder.py  partial_emoji.py  template.py
calls.py             guild.py         permissions.py    threads.py
channel.py           http.py          player.py         tracking.py
client.py            __init__.py      profile.py        types
colour.py            integrations.py  __pycache__       user.py
commands.py          interactions.py  py.typed          utils.py
components.py        invite.py        raw_models.py     voice_client.py
connections.py       iterators.py     reaction.py       webhook
context_managers.py  __main__.py      recorder.py       welcome_screen.py
embeds.py            member.py        relationship.py   widget.py

I don't see the ext/ folder anywhere.

rayzchen commented 2 years ago

Ah, i see what is going wrong. Without __init__.py in discord/ext/, setuptools.find_packages() doesn't recognise discord.ext as a subpackage and doesn't include it in the installation. Maybe adding an empty __init__.py file would fix it?

rayzchen commented 2 years ago

Works perfectly with an extra __init__.py file. (other than issue #180)

dolfies commented 2 years ago

Not having an extra __init__.py is deliberate. discord.ext.* shouldn't be imported when you simply import discord, especially since external libs use that namespace.

dolfies commented 2 years ago

Should be good now.