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

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/18883430/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-19 12:09:50  来源:igfitidea点击:

Trouble installing private github repository using pip

pythongitgithubvirtualenvpip

提问by Robeezy

To preface, I have already seen this question Is it possible to use pip to install a package from a private github repository?

作为序言,我已经看到了这个问题Is it possible to use pip to install a package from a private github repository?

I am trying to install a package from a private repository that I have access to using pip.

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

I am able to directly clone it like so:

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

(myenv)robbie@ubuntu:~/git$ git clone [email protected]: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.

But when I try to install it via pip (my virtualenv is activated):

但是当我尝试通过 pip 安装它时(我的 virtualenv 被激活):

(myenv)robbie@ubuntu:~/git$ pip install git+https://[email protected]/matherbk/django-messages.gitDownloading/unpacking git+https://[email protected]/matherbk/django-messages.git
  Cloning https://[email protected]/matherbk/django-messages.git to /tmp/pip-13ushS-build
Password for 'https://[email protected]': 
fatal: Authentication failed
  Complete output from command /usr/bin/git clone -q https://[email protected]/matherbk/django-messages.git /tmp/pip-13ushS-build:

----------------------------------------
Command /usr/bin/git clone -q https://[email protected]/matherbk/django-messages.git /tmp/pip-13ushS-build failed with error code 128 in None
Storing complete log in /home/robbie/.pip/pip.log

I tried typing in my password but it failed. However I am ssh authenticated for [email protected]:

我尝试输入密码,但失败了。但是,我已通过 [email protected] 的 ssh 身份验证:

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

I can switch [email protected]to [email protected]and it lets me install via pip just fine:

我可以切换[email protected][email protected]它,它让我通过 pip 安装就好了:

(myenv)robbie@ubuntu:~/git$ pip install git+https://[email protected]/matherbk/django-messages.git
Downloading/unpacking git+https://[email protected]/matherbk/django-messages.git
  Cloning https://[email protected]/matherbk/django-messages.git to /tmp/pip-SqEan9-build
Password for 'https://[email protected]': 
  Running setup.py egg_info for package from git+https://[email protected]/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...

However I want to do what the first mentioned article does by using [email protected] so that I don't have to add my username into a requirements.txt file and add that to version control.

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

Any thoughts? I previously had this working but had to boot up a fresh image. Thanks ahead of time.

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

采纳答案by Robeezy

It worked by using oxyum's suggestion of changing it to:

它通过使用 oxyum 的建议将其更改为:

pip install git+ssh://[email protected]/matherbk/django-messages.git

回答by Payman

Make sure you use github.com/accountinstead of github.com:accountsee Git+SSH dependencies have subtle (yet critical) differences from git clone

确保您使用 github.com/account而不是 github.com:account查看Git+SSH 依赖项与 git clone 有细微(但关键)的差异

回答by dat789

Had virtualenv activated and had to install a series of applications from github.com from a text file.

激活了 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

However, as @Robeezy suggested, edited the requirement.txt and changed from

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

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

to

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

That is the link provided if you were to clone from the site (only options were Clone or Download).

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

So, thank you! It did work finally.

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

回答by Vito

If you're installing with pip install git+https://github.com/repoand getting this error, make sure your username and password are correct. I was getting this error because I was incorrectly entering my password.

如果您在安装时pip install git+https://github.com/repo遇到此错误,请确保您的用户名和密码正确。我收到此错误是因为我输入了错误的密码。