337

I want to use a new feature of httpie. This feature is in the github repo https://github.com/jkbr/httpie but not in the release on the python package index https://pypi.python.org/pypi/httpie

How can I install the httpie package from the github repo? I tried

pip install https://github.com/jkbr/httpie

But I got an error 'could not unpack'


In Nodejs, I can install packages from github like this

npm install git+https://github.com/substack/node-optimist.git
Colonel Panic
  • 132,665
  • 89
  • 401
  • 465

2 Answers2

537

You need to use the proper git URL:

pip install git+https://github.com/jkbr/httpie.git#egg=httpie

Also see the VCS Support section of the pip documentation.

Don’t forget to include the egg=<projectname> part to explicitly name the project; this way pip can track metadata for it without having to have run the setup.py script.

200_success
  • 7,286
  • 1
  • 43
  • 74
Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
  • 79
    Another [installation option](https://github.com/jkbr/httpie#installation) that doesn't require Git installed: `pip install --upgrade https://github.com/jkbr/httpie/tarball/master` – Jakub Roztocil Mar 07 '13 at 15:35
  • This also solved a problem for me installing a git-hosted package on www.pythonanywhere.com – Arj Jun 07 '15 at 14:04
  • Can I choose a branch? – Nicofisi Dec 21 '17 at 14:20
  • 12
    @Nicofisi: yes, with `@` appended to the URL. See the [VCS support documentation](https://pip.pypa.io/en/stable/reference/pip_install/#vcs-support). – Martijn Pieters Dec 21 '17 at 17:46
  • @JakubRoztocil - will it be always `https://github.com/[user]/[package name]/tarball/master`? I had to install one package from GitHub but didn't know what to type after `[package name]`. I tried `tarball/master` and it worked. I'm just wondering if it'll work each time. – Soren V. Raben Mar 31 '22 at 10:59
  • 1
    @Konrad After `tarball` comes the reference. `master` is the name of the most common default branch, but the reference doesn’t have to be a branch name. You can also use tags or the SHA of a specific commit. Look at the specific repository to see what branches and tags they have. – Martijn Pieters Apr 03 '22 at 20:00
131

To install Python package from github, you need to clone that repository.

git clone https://github.com/jkbr/httpie.git

Then just run the setup.py file from that directory,

sudo python setup.py install
Sagar Rakshe
  • 2,682
  • 1
  • 20
  • 25
  • 15
    too often a python github repo does not have a setup.py file ... see https://github.com/tyiannak/pyAudioAnalysis – Scott Stensland Nov 12 '17 at 14:49
  • 15
    `pip install .` from the locally cloned repo dir will work too. – ccpizza Jun 03 '18 at 19:33
  • @ccpizza `Directory '.' is not installable. Neither 'setup.py' nor 'pyproject.toml' found.` – techkuz Feb 27 '19 at 06:54
  • 4
    @trthhrtz: this means that the package is not compliant and does not meet the requirements as defined in https://packaging.python.org/guides/distributing-packages-using-setuptools/ – ccpizza Feb 27 '19 at 06:59
  • 8
    Install it in develop mode WITHOUT sudo: run `pip install -e .` from inside the root dir of the cloned repo There 2 benefits ot this solution: 1. You can install package in your home projects directory. 1. Package includes `.git` dir, so it's regular Git repository. You can push to your fork right away. [credit for this a goes to @avalanchy from the referred question] – ntg Feb 14 '20 at 09:32
  • getting the following error -> ModuleNotFoundError: No module named 'django_trips' – A.J. Oct 10 '20 at 04:48
  • I get `ImportError: cannot import name '' from '' (unknown location)` when using either `sudo python setup.py install` or `pip install .` or `pip install -e .` and the way I solved this was by looking in `setup.py` and found that I could run `sudo python setup.py bdist_wheel` to generate the `.whl` file, and then `pip install path/to/the.whl` to install. – joe Aug 23 '22 at 00:26