1

I use python 3.7 but also 3.6 and 2.7 are installed, I am using Ubuntu 16.04 LTS.

I changed the order of python to python 2.7 still not working, I am using it on VMware. I guess I made changes to python3, I installed many packages.

I'm trying to run jupyter notebook, but I can't figure out what could cause the problem.

When I try to run ipython from the terminal its shows:

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
0

async has become a reserved keyword starting from Python 3.7, so you have to upgrade your pexpect package.

You can run sudo python3.7 -m pip install --upgrade pexpect. If you still encounter the same error, try removing possibly conflicting versions using sudo apt-get remove python-pexpect python3-pexpect.

7
  • I used the first command, it said command pip3.7 nor found,I tried 2.7 instead,also not found, I used just pip it upgraded but still the same error when runing Ipython – sumer fattoum Dec 22 '20 at 3:10
  • can you maybe please help me via teamwork when is possible ? – sumer fattoum Dec 22 '20 at 3:14
  • Can you please add the output of apt list --installed | grep "pexpect" ? – dariofac Dec 22 '20 at 7:34
  • stealth@ubuntu:~/Desktop$ apt list --installed | grep "pexpect" WARNING: apt does not have a stable CLI interface. Use with caution in scripts. python-pexpect/xenial,now 4.0.1-1 all [installed,automatic] python3-pexpect/xenial,now 4.0.1-1 all [installed] – sumer fattoum Dec 22 '20 at 22:23
  • Did you try the second command (to remove unwanted pexpect conflicting versions)? Alternatively try also running python3.7 -m pip install --upgrade pexpect – dariofac Dec 22 '20 at 22:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.