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
Gabgab2003 opened this Issue Apr 30, 2018 · 11 comments

Comments

Projects
None yet
7 participants
@Gabgab2003

Gabgab2003 commented Apr 30, 2018

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

This comment has been minimized.

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

This comment has been minimized.

ghost commented Jun 16, 2018

when the heck did 3.7 get released

@Harmon758

This comment has been minimized.

Contributor

Harmon758 commented Jul 2, 2018

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 referenced this issue Jul 2, 2018

Closed

help me.. #1387

@yulisunny

This comment has been minimized.

yulisunny commented Jul 3, 2018

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

@Harmon758

This comment has been minimized.

Contributor

Harmon758 commented Jul 3, 2018

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

This comment has been minimized.

yulisunny commented Jul 3, 2018

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!

@tkdberger

This comment has been minimized.

tkdberger 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

This comment has been minimized.

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

This comment has been minimized.

Contributor

Harmon758 commented Aug 11, 2018

@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

This comment has been minimized.

GrayHatter commented Aug 11, 2018

@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

This comment has been minimized.

Contributor

Harmon758 commented Aug 11, 2018

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment