我使用 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
async
从 Python 3.7 开始已经成为保留关键字,所以你必须升级你的pexpect
包。你可以运行
sudo python3.7 -m pip install --upgrade pexpect
。如果您仍然遇到相同的错误,请尝试使用sudo apt-get remove python-pexpect python3-pexpect
.