![](/img/trans.png)
[英]Is it possible to use pip to install a package from a private GitHub repository?
[英]Trouble installing private github repository using pip
作為序言,我已經看到了這個問題Is it possible to use pip to install a package from a private github repository?
我正在嘗試從我有權使用 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 安裝它時(我的 virtualenv 被激活):
(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
我嘗試輸入密碼,但失敗了。 但是,我已通過 git@github.com 的 ssh 身份驗證:
(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 clone 有細微的(但關鍵的)差異
激活了 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 建議的那樣,編輯了requirements.txt 並從
-e git://github.com...
到
-e git+https://github.com...
如果您要從站點進行克隆(只有選項是克隆或下載),則這是提供的鏈接。
所以謝謝! 它終於奏效了。
如果您使用pip install git+https://github.com/repo
並收到此錯誤,請確保您的用戶名和密碼正確。 我收到此錯誤是因為我輸入了錯誤的密碼。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.