我使用 python 3.7,但也安装了 3.6 和 2.7,我正在使用 Ubuntu 16.04 LTS。
我把 python 的顺序改成了 python 2.7 仍然不起作用,我在 VMware 上使用它。我想我对 python3 做了更改,我安装了很多包。
我正在尝试运行 jupyter notebook,但我不知道是什么导致了这个问题。
当我尝试从终端运行 ipython 时,它显示:
stealth@ubuntu:~/Desktop$ ipython
Traceback (most recent call last):
File "/home/stealth/.local/bin/ipython", line 7, in <module>
from IPython import start_ipython
File "/home/stealth/.local/lib/python3.7/site-packages/IPython/__init__.py", line 55, in <module>
from .core.application import Application
File "/home/stealth/.local/lib/python3.7/site-packages/IPython/core/application.py", line 25, in <module>
from IPython.core import release, crashhandler
File "/home/stealth/.local/lib/python3.7/site-packages/IPython/core/crashhandler.py", line 27, in <module>
from IPython.core import ultratb
File "/home/stealth/.local/lib/python3.7/site-packages/IPython/core/ultratb.py", line 116, in <module>
from IPython.utils import path as util_path
File "/home/stealth/.local/lib/python3.7/site-packages/IPython/utils/path.py", line 17, in <module>
from IPython.utils.process import system
File "/home/stealth/.local/lib/python3.7/site-packages/IPython/utils/process.py", line 19, in <module>
from ._process_posix import system, getoutput, arg_split, check_pid
File "/home/stealth/.local/lib/python3.7/site-packages/IPython/utils/_process_posix.py", line 23, in <module>
import pexpect
File "/usr/lib/python3/dist-packages/pexpect/__init__.py", line 75, in <module>
from .pty_spawn import spawn, spawnu
File "/usr/lib/python3/dist-packages/pexpect/pty_spawn.py", line 15, in <module>
from .spawnbase import SpawnBase
File "/usr/lib/python3/dist-packages/pexpect/spawnbase.py", line 218
def expect(self, pattern, timeout=-1, searchwindowsize=-1, async=False):
^
SyntaxError: invalid syntax
答案1
async
从 Python 3.7 开始已成为保留关键字,因此你必须升级你的pexpect
包。
您可以运行sudo python3.7 -m pip install --upgrade pexpect
。如果仍然遇到相同的错误,请尝试使用 删除可能有冲突的版本sudo apt-get remove python-pexpect python3-pexpect
。