本文介绍了在python3.6上导入yarl或discord.py时出现问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近更新了discord.py,原因是出现了,更新后我将无法再导入。

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

运行导入不和谐出现以下错误:

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'

列表中的最后一件事是yarl,所以我尝试了导入yarl 并收到此错误:

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'

python的版本为3.6.8。我还在3.6.9的另一台计算机上尝试过此操作,但得到了相同的错误。我已经在装有3.7.7的计算机上尝试了此方法,并且一切正常加载,但是我无法在此计算机上将python升级到3.7,因此希望在3.6上运行它。

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.

推荐答案

升级 pip 并没有帮助我。

如@Orangutan所示,强制重新安装 yarl 并没有帮助我。

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

这篇关于在python3.6上导入yarl或discord.py时出现问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-13 13:33