Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Installing Python Package from Github Using PIP

Tags:

python

github

pip

I've seen it documented that you can install a Github hosting Python package using pip via:

sudo pip install -e git+git://github.com/myuser/myproject.git#egg=myproject

However, this appears to install the package to the current working directory, which is almost never where is should be.

How do you instruct pip to install it into the standard Python package directory (e.g. on Ubuntu this is /usr/local/lib/python2.6/dist-packages)?

like image 427
Cerin Avatar asked Feb 22 '12 20:02

Cerin


People also ask

Can you pip install from GitHub?

You can deploy Git locally, or use it via a hosted service, such as Github, Gitlab or Bitbucket. One of the advantages of using pip together with Git is to install the latest commits of unreleased Python packages as branches from Github.

Can you install Python packages using pip?

Most Python packages are now designed to be compatible with pip. If you have a package that's not compatible, then you'll need to do a manual installation. How to manually install a Python package: Download the package and extract it into a local directory.


2 Answers

The -e flag tells pip to install it as "editable", i.e. keep the source around. Drop the -e flag and it should do about what you expect.

sudo pip install git+git://github.com/myuser/myproject.git#egg=myproject

If that doesn't work try using https instead of git.

sudo pip install git+https://github.com/myuser/myproject.git#egg=myproject
like image 179
mattbornski Avatar answered Oct 06 '22 13:10

mattbornski


For Python 3 make sure you have python3-pip installed (and of course git installed):

The syntax just changed to:

sudo pip3 install git+git://github.com/someuser/someproject.git
like image 39
tobias47n9e Avatar answered Oct 06 '22 13:10

tobias47n9e