从 Python 3.5.1 升级到 3.6:SyntaxError: 'yield' inside async function [英] Upgrading from Python 3.5.1 to 3.6: SyntaxError: 'yield' inside async function

查看:92
本文介绍了从 Python 3.5.1 升级到 3.6:SyntaxError: 'yield' inside async function的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是 Windows 8.1,想从 Python 3.5.1 升级到 Python 3.6.我目前使用 Anaconda3 并拥有适用于 python 2.7 和 python 3.5 的虚拟环境.

I am on Windows 8.1 and wanted to upgrade from Python 3.5.1 to Python 3.6. I currently use Anaconda3 and have virtual environments for python 2.7 and python 3.5.

我使用了以下升级方式:升级前-

I used the following way of upgrading: Before upgradation-

C:\Users\thisuser>python --version 
Python 3.5.1 :: Anaconda 2.4.1 (64-bit)

使用以下方法完成升级:

Upgradation done using:

C:\Users\thisuser>conda install python=3.6

以上运行成功,进度完成.

The above ran successfully and the progress was complete.

但在此之后,由于以下问题,我无法运行任何 python 代码:

But after this point, I am unable to run any python code because of the following issue:

C:\Users\thisuser>python
Failed to import the site module
Traceback (most recent call last):
  File "C:\Users\thisuser\AppData\Local\Continuum\Anaconda3\lib\site.py", line 73, in <module
>
    import os
  File "C:\Users\thisuser\AppData\Local\Continuum\Anaconda3\lib\os.py", line 652, in <module>

    from _collections_abc import MutableMapping
  File "C:\Users\thisuser\AppData\Local\Continuum\Anaconda3\lib\_collections_abc.py", line 64

    async def _ag(): yield
                    ^
SyntaxError: 'yield' inside async function

无论我做什么,无论是尝试运行现有的 python 代码还是激活 python2 环境或预先存在的 python3 环境,我都会得到与上述完全相同的错误.检查 python 版本与以前相同,即

No matter what I do, whether trying to run an existing python code or activate python2 environment or pre-existing python3 enviroment, I get the exact same error as above. Checking the python version gives the same as before i.e.,

C:\Users\thisuser>python --version 
Python 3.5.1 :: Anaconda 2.4.1 (64-bit)

任何建议都会很棒.谢谢.

Any suggestions would be great. Thanks.

编辑 1:发现这个错误报告:https://bugs.python.org/review/28003/diff/18396/Lib/types.py?context=50&column_width=80

无法理解如何利用它来解决问题.已尝试注释掉 _collections_abc.py 中代码的相关部分,但这会导致其他奇怪的错误.

Can't understand how to make use of this to fix the issue. Have tried commenting out the relevant portion of the code in _collections_abc.py but this leads to other strange errors.

推荐答案

(Windows 10)我遇到了同样的问题,但意识到 Pycharm 上的项目解释器"仍设置为 3.5,而 PYTHONPATH 设置为 3.6 可执行文件.将项目解释器"更改为 3.6 并解决了问题

(Windows 10) I had same issue but realized that the "Project Interpreter" on my Pycharm was still set to 3.5 while PYTHONPATH was set to 3.6 executable. Changed "Project Interpreter" to 3.6 and issue solved

这篇关于从 Python 3.5.1 升级到 3.6:SyntaxError: 'yield' inside async function的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆