使用 pip 安装私有 github 存储库时遇到问题



前言,我已经看到了这个问题是否可以使用 pip 从私有 github 存储库安装软件包?

正在尝试从我可以使用 pip 访问的私有存储库安装一个包。

我可以直接像这样克隆它:

(myenv)robbie@ubuntu:~/git$ git clone git@github.com:matherbk/django-messages.git
Cloning into 'django-messages'...
remote: Counting objects: 913, done.
remote: Compressing objects: 100% (345/345), done.
remote: Total 913 (delta 504), reused 913 (delta 504)
Receiving objects: 100% (913/913), 165.73 KiB, done.
Resolving deltas: 100% (504/504), done.

但是当我尝试通过 pip 安装它时(我的虚拟环境已激活):

(myenv)robbie@ubuntu:~/git$ pip install git+https://git@github.com/matherbk/django-messages.gitDownloading/unpacking git+https://git@github.com/matherbk/django-messages.git
  Cloning https://git@github.com/matherbk/django-messages.git to /tmp/pip-13ushS-build
Password for 'https://git@github.com': 
fatal: Authentication failed
  Complete output from command /usr/bin/git clone -q https://git@github.com/matherbk/django-messages.git /tmp/pip-13ushS-build:
----------------------------------------
Command /usr/bin/git clone -q https://git@github.com/matherbk/django-messages.git /tmp/pip-13ushS-build failed with error code 128 in None
Storing complete log in /home/robbie/.pip/pip.log

我尝试输入密码,但失败了。但是,我已通过 ssh 身份验证 git@github.com:

(myenv)robbie@ubuntu:~/git$ ssh -T git@github.com
Hi robpodosek! You've successfully authenticated, but GitHub does not provide shell access.

我可以git@github.com切换到robpodosek@github.com,它让我可以通过 pip 安装就可以了:

(myenv)robbie@ubuntu:~/git$ pip install git+https://robpodosek@github.com/matherbk/django-messages.git
Downloading/unpacking git+https://robpodosek@github.com/matherbk/django-messages.git
  Cloning https://robpodosek@github.com/matherbk/django-messages.git to /tmp/pip-SqEan9-build
Password for 'https://robpodosek@github.com': 
  Running setup.py egg_info for package from git+https://robpodosek@github.com/matherbk/django-messages.git
    warning: no files found matching 'README'
Installing collected packages: django-messages
  Running setup.py install for django-messages
    warning: no files found matching 'README'
Successfully installed django-messages
Cleaning up...

但是,我想通过使用 git@github.com 来执行第一篇提到的文章所做的事情,这样我就不必将我的用户名添加到 requirements.txt 文件中并将其添加到版本控制中。

有什么想法吗?我以前有这个工作,但不得不启动一个新的映像。提前谢谢。

它通过使用 oxyum 的建议将:更改为/来工作:

pip install git+ssh://git@github.com/matherbk/django-messages.git

确保使用 github.com /account 而不是 github.com :account请参阅 Git+SSH 依赖项与 git 克隆有细微(但关键)的差异

激活了 virtualenv,并且必须从文本文件 github.com 安装一系列应用程序。

(venv)$ cat requirements.txt
-e git://github.com/boto/botocore.git@develop#egg=botocore
-e git://github.com/boto/jmespath.git@develop#egg=jmespath
-e git://github.com/boto/s3transfer.git@develop#egg=s3transfer
nose==1.3.3
mock==1.3.0
wheel==0.24.0
unittest2==0.5.1; python_version == '2.6'
(venv)$ pip install -r requirements.txt
Ignoring unittest2: markers 'python_version == "2.6"' don't match your environment Obtaining botocore from git+git://github.com/boto/botocore.git@develop#egg=botocore (from -r requirements.txt (line 1))
Cloning git://github.com/boto/botocore.git (to develop) to ./venv/src/botocore
fatal: unable to connect to github.com:
github.com[0: 192.30.253.112]: errno=Connection timed out
github.com[1: 192.30.253.113]: errno=Connection timed out
Command "git clone -q git://github.com/boto/botocore.git 
/home/ubuntu/utils/boto3/venv/src/botocore" failed with error code 128 in None

但是,正如@Robeezy所建议的那样,编辑了要求.txt并从

-e git://github.com...

-e git+https://github.com...

如果您要从站点克隆,则提供的链接(只有"克隆"或"下载"选项)。

所以,谢谢!它终于奏效了。

如果您使用 pip install git+https://github.com/repo 进行安装并收到此错误,请确保您的用户名和密码正确无误。我收到此错误,因为我输入的密码不正确。

最新更新