Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Problem importing yarl or discord.py on python3.6

I recently updated discord.py due to an error outlined in this post and after updating it I can no longer import it.

Running import discord brings up the following error:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.6/site-packages/discord/__init__.py", line 23, in <module>
    from .client import Client
  File "/usr/local/lib/python3.6/site-packages/discord/client.py", line 34, in <module>
    import aiohttp
  File "/usr/local/lib/python3.6/site-packages/aiohttp/__init__.py", line 6, in <module>
    from .client import BaseConnector as BaseConnector
  File "/usr/local/lib/python3.6/site-packages/aiohttp/client.py", line 30, in <module>
    from yarl import URL
  File "/usr/local/lib/python3.6/site-packages/yarl/__init__.py", line 1, in <module>
    from ._url import URL, cache_clear, cache_configure, cache_info
  File "/usr/local/lib/python3.6/site-packages/yarl/_url.py", line 56, in <module>
    @rewrite_module
  File "/usr/local/lib/python3.6/site-packages/yarl/_url.py", line 132, in URL
    _QUERY_PART_QUOTER = _Quoter(safe="?/:@", qs=True, requote=False)
  File "yarl/_quoting.pyx", line 192, in yarl._quoting._Quoter.__init__
TypeError: __init__() got an unexpected keyword argument 'requote'

The last thing on the list was yarl, so I tried an import yarl and got this error:

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/yarl/__init__.py", line 1, in <module>
    from ._url import URL, cache_clear, cache_configure, cache_info
  File "/usr/local/lib/python3.6/site-packages/yarl/_url.py", line 56, in <module>
    @rewrite_module
  File "/usr/local/lib/python3.6/site-packages/yarl/_url.py", line 132, in URL
    _QUERY_PART_QUOTER = _Quoter(safe="?/:@", qs=True, requote=False)
  File "yarl/_quoting.pyx", line 192, in yarl._quoting._Quoter.__init__
TypeError: __init__() got an unexpected keyword argument 'requote'

The version of python is 3.6.8. I've also tried this on a different machine with 3.6.9 and got the same error. I've tried this on a machine with 3.7.7 and everything loaded normally, but I do not have the ability to upgrade python to 3.7 on this machine and so would like to get it to work on 3.6.

like image 832
ibid Avatar asked Dec 05 '25 04:12

ibid


2 Answers

Upgrading pip did not help me.

Forcing the reinstall of yarl as shown by @Orangutan did not help me.

However, the following did the trick:

mkdir ~/backup
mv ~/.local/lib/python3.6/site-packages/yarl* ~/backup/
pip3 install yarl --force-reinstall --no-cache-dir
like image 168
ikegami Avatar answered Dec 07 '25 02:12

ikegami


Updating to yarl 1.5.1 should fix this. The GitHub Issue suggests it was an issue with internal C code being published.

  • Changelog
  • PyPI Page
  • Fixing PR
  • GitHub Release
  • v1.5.0...v1.5.1 diff
like image 35
Orangutan Avatar answered Dec 07 '25 02:12

Orangutan