0

I'm using Ubuntu 16.04 , when I enter pip --version in the terminal I get this error.

Traceback (most recent call last):
  File "/home/diyazen/.local/bin/pip", line 4, in <module>
    import re
  File "/usr/lib/python3.5/re.py", line 335, in <module>
    import copyreg
  File "/usr/lib/python2.7/dist-packages/copyreg/__init__.py", line 7, in <module>
    raise ImportError('This package should not be accessible on Python 3. '
ImportError: This package should not be accessible on Python 3. Either you are trying to run from the python-future src folder or your installation of python-future is corrupted.
Error in sys.excepthook:
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 53, in apport_excepthook
    if not enabled():
  File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 24, in enabled
    import re
  File "/usr/lib/python3.5/re.py", line 335, in <module>
    import copyreg
  File "/usr/lib/python2.7/dist-packages/copyreg/__init__.py", line 7, in <module>
    raise ImportError('This package should not be accessible on Python 3. '
ImportError: This package should not be accessible on Python 3. Either you are trying to run from the python-future src folder or your installation of python-future is corrupted.

Original exception was:
Traceback (most recent call last):
  File "/home/diyazen/.local/bin/pip", line 4, in <module>
    import re
  File "/usr/lib/python3.5/re.py", line 335, in <module>
    import copyreg
  File "/usr/lib/python2.7/dist-packages/copyreg/__init__.py", line 7, in <module>
    raise ImportError('This package should not be accessible on Python 3. '
ImportError: This package should not be accessible on Python 3. Either you are trying to run from the python-future src folder or your installation of python-future is corrupted.

I searched for this error and one solution was provided on one of the threads here to

unset PYTHONPATH "This package should not be accessible on Python 3" when running python3

After unsetting python path and again running the pip --version I get this error.

Traceback (most recent call last):
  File "/home/diyazen/.local/bin/pip", line 7, in <module>
    from pip._internal.cli.main import main
  File "/home/diyazen/.local/lib/python3.5/site-packages/pip/_internal/cli/main.py", line 57
    sys.stderr.write(f"ERROR: {exc}")
                                   ^
SyntaxError: invalid syntax

Has anyone else also had similar error/ if so how to resolve these kind of error/. Thank you .

Dinoj
  • 17
  • 6
  • 1
    It looks like your python3 is trying to access pip for your python2. What happens if you try something like `python3 -m pip --version`? – M Z Apr 27 '23 at 06:26
  • Hello @MZ Thank you very much for your reply on my issue. Im getting this error https://pastebin.com/vwQDQp9H after adding it – Dinoj Apr 27 '23 at 06:35
  • 1
    First check, if pip is installed - `which pip`. If not then you run - `sudo apt-get install python3-pip`. You need to include pip binary path in .bashrc - `export PATH=$PATH:~/.local/bin`. Then you have to run correct version of the python - `python3 -m pip --version` – Pravash Panigrahi Apr 27 '23 at 06:45
  • 1
    https://stackoverflow.com/q/65869296/7976758 Found in https://stackoverflow.com/search?q=%5Bpip%5D+sys.stderr.write%28f%22ERROR%3A+%7Bexc%7D%22%29 – phd Apr 27 '23 at 06:51
  • What's in `~/.local/bin/pip` and why? – tripleee Apr 27 '23 at 07:02
  • thank you very much for your supportive comments. I was able to resolve the issue thanks to the comments provided here – Dinoj Apr 27 '23 at 07:33

0 Answers0