1

When I run

#pip3 

command I received below error.

Traceback (most recent call last):
  File "/usr/bin/pip3", line 9, in <module>
    from pip import main
  File "/usr/lib/python2.7/dist-packages/pip/__init__.py", line 16, in <module>
    from pip.vcs import git, mercurial, subversion, bazaar  # noqa
  File "/usr/lib/python2.7/dist-packages/pip/vcs/subversion.py", line 9, in <module>
    from pip.index import Link
  File "/usr/lib/python2.7/dist-packages/pip/index.py", line 30, in <module>
    from pip.wheel import Wheel, wheel_ext
  File "/usr/lib/python2.7/dist-packages/pip/wheel.py", line 6, in <module>
    import compileall
  File "/usr/lib/python3.5/compileall.py", line 20, in <module>
    from concurrent.futures import ProcessPoolExecutor
  File "/usr/lib/python2.7/dist-packages/concurrent/futures/__init__.py", line 8, in <module>
    from concurrent.futures._base import (FIRST_COMPLETED,
  File "/usr/lib/python2.7/dist-packages/concurrent/futures/_base.py", line 357
    raise type(self._exception), self._exception, self._traceback
                               ^
SyntaxError: invalid syntax

what I tried to resolve ?

Step 1 - Uninstall

sudo apt-get remove python3-pip

Step 2 - Delete the directory

   /usr/local/lib/python3.5/dist-packages

Step 3 - Reinstall pip3

sudo apt-get install python3-pip

When i run pip3 command i still get the same error mentioned above.

Much appreciated the help?.

Note Ubuntu Version:

DISTRIB_ID=Ubuntu

DISTRIB_RELEASE=16.04

DISTRIB_CODENAME=xenial

DISTRIB_DESCRIPTION="Ubuntu 16.04.5 LTS"

5
  • 1
    Do you have PYTHONPATH set somewhere?
    – mchid
    May 3, 2020 at 3:42
  • What do you get with python -V; python3 -V. Most issues I've seen relate to users changing their default python versions... I'd also check your system is fully-upgraded; as 16.04.5 implies you've not fully-upgraded since before 2019-Mar-01 (fridge.ubuntu.com/2019/03/01/ubuntu-16-04-6-lts-released) as your system should have reported 16.04.6 which could also be your problem too.
    – guiverc
    May 3, 2020 at 3:42
  • 1
    If you have PYTHONPATH set somewhere, you need to unset it or comment it out and then source the file. For example, if you have it set in ~/.bashrc comment out the line with the PYTHONPATH and then run . ~/.bashrc to source the file and then run export PYTHONPATH='' for good measure. Let me know if you have it set and I will make this an answer.
    – mchid
    May 3, 2020 at 3:46
  • 1
    To see if it is set, run: echo $PYTHONPATH and it should return nothing. If you get response, follow my previous comment to unset it.
    – mchid
    May 3, 2020 at 3:51
  • thanks @mchid. rocking. I used PYTHONPATH set in the .bashrc to 2.7 version. Also, i removed all the ros related packages. now i am able to see the output below pip 8.1.1 from /usr/lib/python3/dist-packages (python 3.5). thanks for your wonderful reply.
    – Whoami
    May 3, 2020 at 4:08

1 Answer 1

1

This problem happens sometimes when PYTHONPATH is set somewhere.

To see if it is set run the following command:

echo $PYTHONPATH 

If the command returns a path, you need to unset PYTHONPATH.

If you have it set in ~/.bashrc comment out the line for PYTHONPATH and then run:

. ~/.bashrc 

to source the file and then run:

export PYTHONPATH='' 

for good measure.

Reference1 and Reference2

Also, see this related question.

1
  • I was about to ask you to keep the separate post so that i can thumbs up. ;)
    – Whoami
    May 3, 2020 at 7:53

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .