pycord icon indicating copy to clipboard operation
pycord copied to clipboard

Error, async_.py

Open QuartzWarrior opened this issue 5 years ago • 30 comments

Summary

It tries to import https://github.com/Pycord-Development/pycord/blob/6d30c5b7764ff87f3102ddef32c656f463b26132/discord/channel.py#L2033 in file https://github.com/Pycord-Development/pycord/blob/master/discord/webhook/async_.py#L46

Reproduction Steps

I ran my bot,

python3.9 MinecraftBot.py

Minimal Reproducible Code

import json, requests, discord, asyncio, time, itertools, os, topgg

Expected Results

Everything to run smoothly and the Slash commands to be working.

Actual Results

Traceback (most recent call last):
  File "/home/quartz_i_warrior/MinecraftBot.py", line 1, in <module>
    import json, requests, discord, asyncio, time, itertools, os, topgg
  File "/home/quartz_i_warrior/.local/lib/python3.9/site-packages/discord/__init__.py", line 25, in <module>
    from .client import Client
  File "/home/quartz_i_warrior/.local/lib/python3.9/site-packages/discord/client.py", line 53, in <module>
    from .webhook import Webhook
  File "/home/quartz_i_warrior/.local/lib/python3.9/site-packages/discord/webhook/__init__.py", line 12, in <module>
    from .async_ import *
  File "/home/quartz_i_warrior/.local/lib/python3.9/site-packages/discord/webhook/async_.py", line 46, in <module>
    from ..channel import PartialMessageable
ImportError: cannot import name 'PartialMessageable' from 'discord.channel' (/home/quartz_i_warrior/.local/lib/python3.9/site-packages/discord/channel.py)

Intents

None.

System Information

  • Python v3.9.7-final
  • discord.py v1.7.3-final
  • aiohttp v3.7.4.post0
  • system info: Linux 4.19.0-17-cloud-amd64 #1 SMP Debian 4.19.194-2 (2021-06-21)

Checklist

  • [X] I have searched the open issues for duplicates.
  • [X] I have shown the entire traceback, if possible.
  • [X] I have removed my token from display, if visible.

Additional Context

The error starts here when importing from here.

QuartzWarrior avatar Sep 19 '21 14:09 QuartzWarrior

Cannot reproduce...this is an installation error please uninstall py-cord and reinstall from git pip uninstall py-cord pip install -U git+https://github.com/Pycord-Development/pycord

ufywufy avatar Sep 20 '21 01:09 ufywufy

hmmm ok, I had done:

git clone https://github.com/Pycord-Development/pycord
cd pycord
python3.9 -m pip -U install .

and I re-installed it and uninstalled it multiple times in hopes of fixing it.

Was the way I did it bad or something? Thanks.

QuartzWarrior avatar Sep 20 '21 03:09 QuartzWarrior

No, but did you uninstall discord.py first?

pip uninstall discord.py -y

izxxr avatar Sep 20 '21 12:09 izxxr

Yes, but I forgot the - y part

QuartzWarrior avatar Sep 20 '21 13:09 QuartzWarrior

It doesn't matter, -y is just a shortcut flag that will auto-confirm uninstallation.

Dorukyum avatar Sep 20 '21 13:09 Dorukyum

Still getting the same error:

Traceback (most recent call last):
  File "/home/quartz_i_warrior/MinecraftBot.py", line 3, in <module>
    from discord.ext import commands, tasks
  File "/home/quartz_i_warrior/.local/lib/python3.9/site-packages/discord/__init__.py", line 25, in <module>
    from .client import Client
  File "/home/quartz_i_warrior/.local/lib/python3.9/site-packages/discord/client.py", line 53, in <module>
    from .webhook import Webhook
  File "/home/quartz_i_warrior/.local/lib/python3.9/site-packages/discord/webhook/__init__.py", line 12, in <module>
    from .async_ import *
  File "/home/quartz_i_warrior/.local/lib/python3.9/site-packages/discord/webhook/async_.py", line 46, in <module>
    from ..channel import PartialMessageable
ImportError: cannot import name 'PartialMessageable' from 'discord.channel' (/home/quartz_i_warrior/.local/lib/python3.9/site-packages/discord/channel.py)

QuartzWarrior avatar Sep 20 '21 17:09 QuartzWarrior

Ok, I just installed wheel then reinstalled py-cord, cause it turned out I didn't have it, but now am getting this error:

Traceback (most recent call last):
  File "/home/quartz_i_warrior/.local/lib/python3.9/site-packages/discord/ext/commands/bot.py", line 660, in _load_from_module_spec
    spec.loader.exec_module(lib)  # type: ignore
  File "<frozen importlib._bootstrap_external>", line 850, in exec_module
  File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
  File "/home/quartz_i_warrior/Moderation.py", line 4, in <module>
    from discord.ext.commands.errors import ExtensionNotFound, ExtensionNotLoaded, MissingPermissions
ImportError: cannot import name 'ExtensionNotFound' from 'discord.ext.commands.errors' (/home/quartz_i_warrior/.local/lib/python3.9/site-packages/discord/ext/commands/errors.py)

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/quartz_i_warrior/MinecraftBot.py", line 158, in <module>
    client.load_extension(cog)
  File "/home/quartz_i_warrior/.local/lib/python3.9/site-packages/discord/ext/commands/bot.py", line 732, in load_extension
    self._load_from_module_spec(spec, name)
  File "/home/quartz_i_warrior/.local/lib/python3.9/site-packages/discord/ext/commands/bot.py", line 663, in _load_from_module_spec
    raise discord.ExtensionFailed(key, e) from e
discord.errors.ExtensionFailed: Extension 'Moderation' raised an error: ImportError: cannot import name 'ExtensionNotFound' from 'discord.ext.commands.errors' (/home/quartz_i_warrior/.local/lib/python3.9/site-packages/discord/ext/commands/errors.py)

Just a note, the stable version of py-cord works.

QuartzWarrior avatar Sep 20 '21 17:09 QuartzWarrior

The extension errors were moved in 7c4b4933fe9a091d1cdc5bc7214dc2b5de9191c9

esmaycat avatar Sep 20 '21 17:09 esmaycat

hmm how do I replace those then?

nvm

QuartzWarrior avatar Sep 20 '21 17:09 QuartzWarrior

Well they were moved to discord.errors so I guess you import then from there instead.

esmaycat avatar Sep 20 '21 17:09 esmaycat

So, is there an easy way to transfer all these discord.py files to py-cord?

QuartzWarrior avatar Sep 20 '21 17:09 QuartzWarrior

Also, is there a different method for importing from discord.ext import commands, tasks now?

Because the error starts with

Traceback (most recent call last):
  File "/home/quartz_i_warrior/MinecraftBot.py", line 3, in <module>
    from discord.ext import commands, tasks

QuartzWarrior avatar Sep 20 '21 17:09 QuartzWarrior

Yep, getting the same error

Traceback (most recent call last):
  File "/Users/nimboss/Desktop/Programming/Discord Bots/GitHub Utils/githubutils.py", line 1, in <module>
    from discord.ext.commands import Bot
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/discord/__init__.py", line 25, in <module>
    from .client import Client
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/discord/client.py", line 53, in <module>
    from .webhook import Webhook
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/discord/webhook/__init__.py", line 12, in <module>
    from .async_ import *
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/discord/webhook/async_.py", line 46, in <module>
    from ..channel import PartialMessageable
ImportError: cannot import name 'PartialMessageable' from 'discord.channel' (/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/discord/channel.py)

ImNimboss avatar Sep 21 '21 08:09 ImNimboss

My installation's from git

ImNimboss avatar Sep 21 '21 09:09 ImNimboss

Update: uninstalling and reinstalling worked for me

ImNimboss avatar Sep 21 '21 09:09 ImNimboss

@QuartzWarrior could you try reinstalling?

Dorukyum avatar Sep 21 '21 09:09 Dorukyum

I have done that multiple times... But yes, I could try again.

QuartzWarrior avatar Sep 21 '21 12:09 QuartzWarrior

Traceback (most recent call last):
  File "/home/quartz_i_warrior/.local/lib/python3.9/site-packages/discord/ext/commands/bot.py", line 660, in _load_from_module_spec
    spec.loader.exec_module(lib)  # type: ignore
  File "<frozen importlib._bootstrap_external>", line 850, in exec_module
  File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
  File "/home/quartz_i_warrior/Moderation.py", line 4, in <module>
    from discord.errors import ExtensionNotFound, ExtensionNotLoaded, MissingPermissions
ImportError: cannot import name 'MissingPermissions' from 'discord.errors' (/home/quartz_i_warrior/.local/lib/python3.9/site-packages/discord/errors.py)

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/quartz_i_warrior/MinecraftBot.py", line 158, in <module>
    client.load_extension(cog)
  File "/home/quartz_i_warrior/.local/lib/python3.9/site-packages/discord/ext/commands/bot.py", line 732, in load_extension
    self._load_from_module_spec(spec, name)
  File "/home/quartz_i_warrior/.local/lib/python3.9/site-packages/discord/ext/commands/bot.py", line 663, in _load_from_module_spec
    raise discord.ExtensionFailed(key, e) from e
discord.errors.ExtensionFailed: Extension 'Moderation' raised an error: ImportError: cannot import name 'MissingPermissions' from 'discord.errors' (/home/quartz_i_warrior/.local/lib/python3.9/site-packages/discord/errors.py)

QuartzWarrior avatar Sep 21 '21 16:09 QuartzWarrior

File "/home/quartz_i_warrior/Moderation.py"

This problem is related to your code as I understood.

Dorukyum avatar Sep 21 '21 16:09 Dorukyum

Yes, but if I go to the errors page, it shows that it is not there.

QuartzWarrior avatar Sep 21 '21 16:09 QuartzWarrior