是否可以使用pip在自托管gitlab中通过ssh安装包?

时间:2014-11-17 18:16:23

标签: ssh pip gitlab

我有一个自托管的gitlab,我想使用ssh安装一个托管的软件包。

我试过了:

pip install git+ssh://git@<my_domain>:se7entyse7en/<project_name>.git

这是输出:

Downloading/unpacking git+ssh://git@<my_domain>:se7entyse7en/<project_name>.git
Cloning ssh://git@<my_domain>:se7entyse7en/<project_name>.git to /var/folders/3r/v7swlvdn2p7_wyh9wj90td2m0000gn/T/pip-4_JdRU-build
ssh: Could not resolve hostname <my_domain>:se7entyse7en: nodename nor servname provided, or not known
fatal: Could not read from remote repository.

Please make sure you have the correct access rights and the repository exists.

更新

我试图在gitlab.com上传它,在上传了repo后我尝试通过运行来安装它:

pip install git+ssh://git@gitlab.com:loumarvincaraig/<project_name>.git

但没有改变。特别是pip.log

的内容
/Users/se7entyse7en/Envs/test/bin/pip run on Mon Nov 17 22:14:51 2014
Downloading/unpacking git+ssh://git@gitlab.com:loumarvincaraig/<project_name>.git

Cloning ssh://git@gitlab.com:loumarvincaraig/<project_name>.git to /var/folders/3r/v7swlvdn2p7_wyh9wj90td2m0000gn/T/pip-91JVFi-build

Found command 'git' at '/usr/local/bin/git'
Running command /usr/local/bin/git clone -q ssh://git@gitlab.com:loumarvincaraig/<project_name>.git /var/folders/3r/v7swlvdn2p7_wyh9wj90td2m0000gn/T/pip-91JVFi-build
Complete output from command /usr/local/bin/git clone -q ssh://git@gitlab.com:loumarvincaraig/<project_name>.git /var/folders/3r/v7swlvdn2p7_wyh9wj90td2m0000gn/T/pip-91JVFi-build:

Cleaning up...

Command /usr/local/bin/git clone -q ssh://git@gitlab.com:loumarvincaraig/<project_name>.git /var/folders/3r/v7swlvdn2p7_wyh9wj90td2m0000gn/T/pip-91JVFi-build failed with error code 128 in None

Exception information:
Traceback (most recent call last):
File "/Users/se7entyse7en/Envs/test/lib/python2.7/site-packages/pip/basecommand.py", line 134, in main
status = self.run(options, args)
File "/Users/se7entyse7en/Envs/test/lib/python2.7/site-packages/pip/commands/install.py", line 236, in run
requirement_set.prepare_files(finder, force_root_egg_info=self.bundle, bundle=self.bundle)
File "/Users/se7entyse7en/Envs/test/lib/python2.7/site-packages/pip/req.py", line 1092, in prepare_files
self.unpack_url(url, location, self.is_download)
File "/Users/se7entyse7en/Envs/test/lib/python2.7/site-packages/pip/req.py", line 1231, in unpack_url
return unpack_vcs_link(link, loc, only_download)
File "/Users/se7entyse7en/Envs/test/lib/python2.7/site-packages/pip/download.py", line 410, in unpack_vcs_link
vcs_backend.unpack(location)
File "/Users/se7entyse7en/Envs/test/lib/python2.7/site-packages/pip/vcs/__init__.py", line 240, in unpack
self.obtain(location)
File "/Users/se7entyse7en/Envs/test/lib/python2.7/site-packages/pip/vcs/git.py", line 111, in obtain
call_subprocess([self.cmd, 'clone', '-q', url, dest])
File "/Users/se7entyse7en/Envs/test/lib/python2.7/site-packages/pip/util.py", line 670, in call_subprocess
% (command_desc, proc.returncode, cwd))
InstallationError: Command /usr/local/bin/git clone -q ssh://git@gitlab.com:loumarvincaraig/<project_name>.git /var/folders/3r/v7swlvdn2p7_wyh9wj90td2m0000gn/T/pip-91JVFi-build failed with error code 128 in None

2 个答案:

答案 0 :(得分:33)

我不知道为什么,但是通过运行以下命令它起作用(斜杠代替:<my_domain>之后):

pip install git+ssh://git@<my_domain>/se7entyse7en/<project_name>.git
#                                    ^
#                             slash instead of :

答案 1 :(得分:0)

是的。这是默认用法:

pip install git+ssh://git@<my_domain>:22/<project_group>/<project_name>.git

使用冒号本身就意味着默认的ssh端口号22。因为您可以控制服务器的端口号,所以端口号可以不同。 Git通过不仅提供:22//来实现自定义。