Httpie: Installing HTTPie on Python 2.7

Created on 9 May 2020  ·  4Comments  ·  Source: httpie/httpie

When I was trying to install the httpie in my ubuntu terminal in windows and I use these command lines which is in the documentation :
pip install --upgrade pip setuptools
pip install --upgrade httpie

I try to check the version with http --version
and then i got this error:

asoom$ http --version
Traceback (most recent call last):
File "/home/abdallah/.local/bin/http", line 8, in <module>
sys.exit(main())
File "/home/abdallah/.local/lib/python2.7/site-packages/httpie/__main__.py", line 10, in main
from .core import main
File "/home/abdallah/.local/lib/python2.7/site-packages/httpie/core.py", line 21
args: List[Union[str, bytes]] = sys.argv,
^
SyntaxError: invalid syntax

and i got the same error with any other http command.

All 4 comments

You use Python 2, which is already end of life. httpie dropped Python 2 support in version 2.0.0 and is now compatible with Python 3 only.

You can try to run pip3 instead if you have it installed along with Python 3.

In addition to @exploide’s advice, you can install the older version that supports Python 2.7 using the following command:

$ pip install 'httpie<2.0.0'

// #886

You use Python 2, which is already end of life. httpie dropped Python 2 support in version 2.0.0 and is now compatible with Python 3 only.

You can try to run pip3 instead if you have it installed along with Python 3.

I try another way to change the default python version, because i have both of them thanks @exploide and @jakubroztocil :
// define the two different python versions:
sudo update-alternatives --install /usr/bin/python python /usr/bin/python2.7 1
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.6 2
// version 3.6 should be defined as default:
sudo update-alternatives --set python /usr/bin/python3.6

This has now been resolved — pip install httpie should work just fine on all Python versions. Having said that, you should really consider upgrading to Python 3.

Was this page helpful?
0 / 5 - 0 ratings