为什么在Jupyter笔记本中使用python 3.5,仅给出SyntaxError:异步def无效语法



我有一个只使用python 3.5设置的virtualenv。当我在那个环境里。

$python --version #gives  python 3.5.1
$python  # in the interpreter.
>>>async def func():pass
>>>func() 

效果很好。我正在使用linux操作系统。

$ipython --version gives 4.0.1
$ipython
ln [1]: async def func():pass
ln [2]: func() # gives <coroutine object func at 0x7f57524b59e8>

这很好用。

但当我启动jupyter笔记本并换上一个新笔记本时。

ln [1]: async def func():pass
        func()     # gives SyntaxError: invalid syntax and points to the first line.

我仔细检查了所有的间距。当我使用时

!which python

它指向仅在virtualenv终端中运行interpreter时使用的相同文件。

在下面与Padric Cunningham交流后,我尝试了Anaconda,并遇到了同样的问题。我清除了我的系统中与木星有关的任何内容。我清理了我的.bashrc、.pythonstartup.py和.profile中的任何我认为可能会妨碍的内容,包括对$PATH和$PYTHONPATH 的更改

我认为问题所在的文件是:

.local/share/jupyter/kernes/python3。

我还删除了我的主目录中的一个.jupyter文件,它似乎是一个遗留文件,以及Padric:提到的文件

/usr/local/share/jupyter/kernes/python3#通过其jupyter文件夹删除。

清理后,我重新安装了Anaconda和jupyter笔记本电脑。Jupyter笔记本现在可以在anaconda虚拟环境中与python 3.5.1配合使用。

最新更新