简体   繁体   English

如何从 gitlab 包安装 pypi 包?

[英]How to install pypi package from gitlab package?

There is a file requirements.txt with many packages build on gitlab so when I try pip install -r file requirements.txt it fails The packages look like this有一个文件requirements.txt,其中有很多包构建在gitlab上,所以当我尝试 pip install -r file requirements.txt 时它失败了包看起来像这样

https:// token :PERSONAL_TOKEN>@gitlab.com/api/v4/projects/<PROJECT_ID>/packages/pypi/simple https://令牌:PERSONAL_TOKEN>@gitlab.com/api/v4/projects/<PROJECT_ID>/packages/pypi/simple

It returns 404 Error它返回 404 错误

Are you trying to automate it?你想自动化吗? (ie without GUI?) (即没有GUI?)

If yes, it is possible.如果是,那是可能的。 Focus on downloading/cloning the entire folder with the wheels to your working directory.专注于使用轮子将整个文件夹下载/克隆到您的工作目录。 It is possible in 2 ways:有两种方式可能:

  1. using raw https (hotlinking) if your repo is public如果您的回购是公开的,则使用原始 https(盗链)
  2. using API like how you are doing if your repo is private如果您的回购是私有的,则使用 API 就像您正在做的那样

Although you are using option 2, it seems your API command is not actually downloading anything.尽管您使用的是选项 2,但您的 API 命令似乎并未实际下载任何内容。 try being more specific.尝试更具体。 For example, to download a numpy.whl file from the root directory a private repository with a Project # of 11:例如,要从根目录下载一个 numpy.whl 文件,一个项目编号为 11 的私有存储库:

mkdir parentfolder\
curl --header "PRIVATE-TOKEN: [PRIVATE_TOKEN]" https://gitlab.com/api/v4/projects/11/repository/files/numpy.whl/raw?ref=master -o parentfolder\numpy.whl
pip install -r requirements.txt --no-index --find-links="parentfolder\"

Make sure you have access to the project containing the packages.确保您有权访问包含包的项目。 If you are logged in (that is, your token is correct) but you don't have access to that repository, GitLab will return a 404 error,如果您已登录(即您的令牌是正确的)但您无权访问该存储库,GitLab 将返回 404 错误,

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM