Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cant Import in Python 3.7.0b3 #1249

Closed
downloadpizza opened this issue Apr 30, 2018 · 14 comments
Closed

Cant Import in Python 3.7.0b3 #1249

downloadpizza opened this issue Apr 30, 2018 · 14 comments
Labels
duplicate This is a duplicate of another issue or PR.

Comments

@downloadpizza
Copy link

Traceback (most recent call last): File "C:/Users/User/PycharmProjects/Python3.7/Challenge.py", line 1, in <module> import discord File "C:\Users\User\AppData\Local\Programs\Python\Python37\lib\site-packages\discord\__init__.py", line 20, in <module> from .client import Client, AppInfo, ChannelPermissions File "C:\Users\User\AppData\Local\Programs\Python\Python37\lib\site-packages\discord\client.py", line 38, in <module> from .state import ConnectionState File "C:\Users\User\AppData\Local\Programs\Python\Python37\lib\site-packages\discord\state.py", line 36, in <module> from . import utils, compat File "C:\Users\User\AppData\Local\Programs\Python\Python37\lib\site-packages\discord\compat.py", line 32 create_task = asyncio.async
python script:
import discord

@Vexs
Copy link
Contributor

Vexs commented Apr 30, 2018

This library does not support 3.7. This error in particular is caused by async becoming a reserved keyword.

Please use Python 3.4-3.6.

@ghost
Copy link

ghost commented Jun 16, 2018

when the heck did 3.7 get released

@Harmon758
Copy link
Contributor

Python 3.7.0 was released on 2018-06-27.

This specific issue was already fixed with 1863a1c (#995).
On the rewrite branch, it was fixed with 0965847 (#900).

Note, the async branch fix is not on PyPI, and the rewrite branch itself is not on PyPI at all.
Please make sure you're up to date with the most recent development version on either branch before making issues.

@Harmon758 Harmon758 mentioned this issue Jul 2, 2018
@yulisunny
Copy link

Thanks for explaining this, how do I install the async branch to my machine?

@Harmon758
Copy link
Contributor

python3 -m pip install -U https://github.com/Rapptz/discord.py/archive/async.zip#egg=discord.py[voice] is probably what you want.
This is outlined in the README in reference to the master branch.
Or see any other resources from a simple Google search for something like "pip install from GitHub".

For future questions like this, you should join either the official discord.py server or the Discord API server for help, as the README recommends.

@yulisunny
Copy link

Thanks a lot for not only providing the answer but also teaching me how to do figure stuff out on my own in the future!

@edwanvi
Copy link

edwanvi commented Aug 11, 2018

I installed the async branch version with python3 -m pip install -U "https://github.com/Rapptz/discord.py/archive/async.zip#egg=discord.py[voice]" (quotes used to make URL cooperate with zsh.) Unfortunately, it looks like this issue is still present.

>>> import discord
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3.7/site-packages/discord/__init__.py", line 20, in <module>
    from .client import Client, AppInfo, ChannelPermissions
  File "/usr/lib/python3.7/site-packages/discord/client.py", line 42, in <module>
    from .voice_client import VoiceClient
  File "/usr/lib/python3.7/site-packages/discord/voice_client.py", line 43, in <module>
    import websockets
  File "/usr/lib/python3.7/site-packages/websockets/__init__.py", line 3, in <module>
    from .client import *
  File "/usr/lib/python3.7/site-packages/websockets/client.py", line 12, in <module>
    from .protocol import CONNECTING, OPEN, WebSocketCommonProtocol
  File "/usr/lib/python3.7/site-packages/websockets/protocol.py", line 17, in <module>
    from .compatibility import asyncio_ensure_future
  File "/usr/lib/python3.7/site-packages/websockets/compatibility.py", line 9
    asyncio_ensure_future = asyncio.async           # Python < 3.5
                                        ^
SyntaxError: invalid syntax

Do I need to switch to the rewrite branch and, well, rewrite my application? It looks like Python 3.7 support was added to websockets in version 6.0 but discord.py requires websockets<4.0

@GrayHatter
Copy link

GrayHatter commented Aug 11, 2018

@tkdberger I open a pull that should hopfully fix this, either way I fixed it with

pip install --upgrade aiohttp
pip install --upgrade websockets

edited to remove --no-deps

@Harmon758
Copy link
Contributor

@tkdberger You're right, but this is a separate issue from the discord.py syntax error this issue is about.
The current pinned dependencies on the async branch don't support Python 3.7. See #1401.

Your options are the following:

  • separately upgrade aiohttp and websockets to the latest versions after installing the async branch from GitHub
  • downgrade to Python 3.6
  • switch to the rewrite branch

I don't recommend the first option as the async branch is not guaranteed to work properly with the latest versions of aiohttp and websockets.

@GrayHatter Upgrading aiohttp and websockets without their dependencies shouldn't be necessary, and might actually cause issues within aiohttp itself, since its dependencies have changed as well.

@GrayHatter
Copy link

@Harmon758 I dropped the no-deps from my post, I went back and tested it and you're correct, it installs correctly without the --no-deps flag as well.

Is the rewrite branch the new hotness? or is async still the more stable version? It's currently set as the default branch on GH, so I assume it's the one I should be using?

@Harmon758
Copy link
Contributor

The rewrite branch is hardly new. It's existed for over 1.5 years now.
The async branch is more stable in the sense that the rewrite branch still has occasional breaking changes and is still under development. This is why the async branch is still the default branch; not because the rewrite branch isn't fully functional.
However, the async branch is only getting bug fixes and isn't getting any new feature updates. As such, the rewrite branch is capable of and handles many new aspects of Discord that are not on the async branch. Not only that, but the rewrite branch includes many improvements and refinements, and generally, any bugs are promptly fixed.

@Cachehuepfer
Copy link

You can edit the lines by yourself:
from create_task = asyncio.async to create_task = getattr(asyncio, 'async')
Thanks to stackoverflow by 'vhs': https://stackoverflow.com/questions/51196568/create-task-asyncio-async-syntaxerror-invalid-syntax

@sethwheway
Copy link
Contributor

As explained, this fixes D.py for 3.7 but the dependencies are not guaranteed to work on 3.7, so don't expect your bot to be stable. We also cannot provide support for someone who was edited the library.

@ashifthekkupuram
Copy link

Phython 3.7 version not working discord bot create

Repository owner locked as resolved and limited conversation to collaborators Apr 13, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
duplicate This is a duplicate of another issue or PR.
Projects
None yet
Development

No branches or pull requests

10 participants