为什么在使用python 3.5的Jupyter笔记本中,只给出了SyntaxError:async def语法无效?

时间:2015-12-29 17:53:35

标签: python jupyter

我有一个仅使用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终端中运行interpereter时使用的相同文件。

1 个答案:

答案 0 :(得分:1)

在我与Padric Cunningham交换之后,我尝试了Anaconda并提出了同样的问题。   我擦除了我的系统中任何与jupyter相关的东西。我清理了.bashrc,.pythonstartup.py和.profile我认为可能会遇到的任何问题,包括对$ PATH和$ PYTHONPATH的更改

我认为问题的原因是:

。本地/共享/ jupyter /内核/ python3。

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

/ usr / local / share / jupyter / kernels / python3 #removed通过它的jupyter文件夹。

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