Search code examples
pythongitpipeasy-install

Installing Python Libraries from GitHub done 4 Ways (unsuccessfully)


I must install a python package/library/module called sonLib from the author's Git repo. It is a dependency of jobTree, which I will also later need. Trouble is it won't install. I've tried 4 methods listed below. Methods 1) and 3) both have the same error which is addressed here, but I could not find an analgous error in his setup.py. Is there one of these errors that is easiest to deal with? Is there perhaps an alternative way to get this (and jobTree) installed so I can import it via the python located in my /usr/bin/python2.7?

Method 1

git clone https://github.com/benedictpaten/sonLib.git
cd /sonLib
sudo python2.7 setup.py install

The Error:

running install
running bdist_egg
running egg_info
creating sonLib.egg-info
writing sonLib.egg-info/PKG-INFO
writing top-level names to sonLib.egg-info/top_level.txt
writing dependency_links to sonLib.egg-info/dependency_links.txt
writing sonLib.egg-info/PKG-INFO
writing top-level names to sonLib.egg-info/top_level.txt
writing dependency_links to sonLib.egg-info/dependency_links.txt
writing manifest file 'sonLib.egg-info/SOURCES.txt'
error: package directory 'sonLib' does not exist

Method 2

sudo pip install -e git://github.com/benedictpaten/sonLib.git

The Error:

Traceback (most recent call last):
  File "/usr/local/bin/pip", line 9, in <module>
    load_entry_point('pip==1.5.6', 'console_scripts', 'pip')()
  File "/usr/local/lib/python3.3/dist-packages/setuptools-5.7-py3.3.egg/pkg_resources.py", line 356, in load_entry_point
    def has_metadata(name):
  File "/usr/local/lib/python3.3/dist-packages/setuptools-5.7-py3.3.egg/pkg_resources.py", line 2472, in load_entry_point
    Split environment marker, add == prefix to version specifiers as
  File "/usr/local/lib/python3.3/dist-packages/setuptools-5.7-py3.3.egg/pkg_resources.py", line 2186, in load
    #@property
ImportError: No module named 'pip'

Method 3

sudo pip install git+https://github.com/benedictpaten/sonLib.git

The Error:

writing manifest file 'pip-egg-info/sonLib.egg-info/SOURCES.txt'
warning: manifest_maker: standard file '-c' not found
error: package directory 'sonLib' does not exist
----------------------------------------
Cleaning up...
Command python setup.py egg_info failed with error code 1 in /tmp/pip-zbppc3-build
Storing complete log in /home/tjm/.pip/pip.log

Method 4

From a related sonLib installation post on SO.

cd /usr/local/lib/python2.7/site-packages/sonLib
sudo git clone https://github.com/benedictpaten/sonLib.git
sudo make all
make test

The Error:

make[1]: Entering directory `/usr/local/lib/python2.7/site-packages/sonLib/C'
make[1]: Nothing to be done for `all'.
make[1]: Leaving directory `/usr/local/lib/python2.7/site-packages/sonLib/C'
PYTHONPATH=.. PATH=../../bin:$PATH python allTests.py --testLength=SHORT --logLevel=CRITICAL
Traceback (most recent call last):
  File "allTests.py", line 8, in <module>
    import bioioTest
  File "/usr/local/lib/python2.7/site-packages/sonLib/bioioTest.py", line 69
    print "Got %s levels, %s fileNo and %s maxTempFiles" % (levels, fileNo, maxTempFiles)
                                                       ^
SyntaxError: invalid syntax
make: *** [test] Error 1

Solution

  • The pip-install-command-syntax you're using might be wrong, after https://pip.pypa.io/en/latest/reference/pip_install.html#git it should be:

    pip install -e git+https://github.com/benedictpaten/sonLib.git#egg=sonLib
    

    "No module named 'pip'" tells you there's no pip available to the current Python-interpreter. As your examples show, you are using several Python-versions. You installed sonLib with Python-2.7 and then you are trying to use pip of Python-3.3. For a bullet-proof way, use virtenv of Python-2.7 and do:

    $ virtenv yourVirtualEnv
    $ cd yourVirtualEnv
    $ . bin/activate
    

    virtenv will install pip along the way, activating it makes sure you'll have its pip available of the commandline, when barely typing pip. After finishing, deactivating the virtualenv again, is simply:

    $ deactivate
    

    Anyway, the activation is not permanently, it will die also, when your shell-session does. Alternatively add the path to your .bashrc, if you want this permanently to be your default pip.