IPython未打开(语法无效)

时间:2018-12-16 04:01:56

标签: linux python-3.x ipython

我已经使用以下命令安装了IPython:

 python3.7 -m pip install ipython

它也提示成功安装,但是当我尝试使用以下命令打开IPython时:

python3.7 -m IPython

(注意:使用IPython代替ipython,因为这是它在我的系统中的存储方式) 我收到以下错误:

 Traceback (most recent call last):
  File "/usr/lib/python3.7/runpy.py", line 183, in _run_module_as_main
    mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
  File "/usr/lib/python3.7/runpy.py", line 142, in _get_module_details
    return _get_module_details(pkg_main_name, error)
  File "/usr/lib/python3.7/runpy.py", line 109, in _get_module_details
    __import__(pkg_name)
  File "/usr/local/lib/python3.7/dist-packages/IPython/__init__.py", line 54, in <module>
    from .core.application import Application
  File "/usr/local/lib/python3.7/dist-packages/IPython/core/application.py", line 25, in <module>
    from IPython.core import release, crashhandler
  File "/usr/local/lib/python3.7/dist-packages/IPython/core/crashhandler.py", line 27, in <module>
    from IPython.core import ultratb
  File "/usr/local/lib/python3.7/dist-packages/IPython/core/ultratb.py", line 119, in <module>
    from IPython.utils import path as util_path
  File "/usr/local/lib/python3.7/dist-packages/IPython/utils/path.py", line 17, in <module>
    from IPython.utils.process import system
  File "/usr/local/lib/python3.7/dist-packages/IPython/utils/process.py", line 19, in <module>
    from ._process_posix import system, getoutput, arg_split, check_pid
  File "/usr/local/lib/python3.7/dist-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 个答案:

答案 0 :(得分:1)

https://github.com/pexpect/pexpect/releases/tag/4.6下载pexpect4.6源代码

提取源代码,进入文件夹并通过以下方式安装pexpect:

sudo python3.7 setup.py install

这应该可以解决您的问题。 :)