从GitHub安装Python库完成4种方法(失败)

时间:2015-08-08 08:06:13

标签: python git pip easy-install

我必须从作者的Git repo安装名为sonLib的python包/库/模块。它是jobTree的依赖关系,我稍后也需要它。麻烦的是它不会安装。我尝试了下面列出的4种方法。方法1)和3)都有相同的错误,here,但我找不到他的setup.py中的分析错误。是否有最容易处理的错误之一?有没有另外一种方法可以安装这个(和jobTree),所以我可以通过我的/usr/bin/python2.7中的python导入它?

方法1

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

错误:

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

方法2

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

错误:

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'

方法3

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

错误:

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

方法4

从相关的sonLib安装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

错误:

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

1 个答案:

答案 0 :(得分:1)

您使用的pip-install-command-syntax可能错误,https://pip.pypa.io/en/latest/reference/pip_install.html#git应该是:

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

&#34;没有名为&#39; pip&#39;&#34;告诉你当前的Python解释器没有可用的pip。如您的示例所示,您使用的是几个Python版本。您使用Python-2.7安装了sonLib,然后尝试使用Python-3.3的pip。对于防弹方式,请使用Python-2.7的virtenv并执行:

$ virtenv yourVirtualEnv
$ cd yourVirtualEnv
$ . bin/activate

virtenv将在此过程中安装pip,激活它会确保在几乎不输入pip时,您的命令行的点数可用。完成后,再次停用virtualenv,只需:

$ deactivate

无论如何,激活不是永久性的,当你的shell会话时,它也会死掉。 或者,如果您希望永久性地将其作为默认点,则将路径添加到.bashrc。