Python:将私有回购分支作为包模块导入

2024-10-01 05:02:34 发布

您现在位置:Python中文网/ 问答频道 /正文

这里是Javascript开发人员。我正在与一个Python团队合作,需要创建一个模块,然后可以供团队使用

要求 私人Github回购 包不是公共的 包从一个回购协议上的分支导出 包裹是从上述分支机构进口到其他个人分支机构的

这可能吗?我试过以下方法:

pip install git+https://github.com/(company-name-here)/(repo-name-here)@compression-module

我收到了以下错误:

ERROR: Command errored out with exit status 1:
     command: /usr/bin/python3 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-req-build-ph2xb8tc/setup.py'"'"'; __file__='"'"'/tmp/pip-req-build-ph2xb8tc/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-3cw8ikqs
         cwd: /tmp/pip-req-build-ph2xb8tc/
    Complete output (5 lines):
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/usr/lib/python3.8/tokenize.py", line 392, in open
        buffer = _builtin_open(filename, 'rb')
    FileNotFoundError: [Errno 2] No such file or directory: '/tmp/pip-req-build-ph2xb8tc/setup.py'
    ----------------------------------------

它似乎试图克隆、签出、切换分支,但在那之后失败了。我想我走对了,但是


Tags: pipnamepybuildegg分支setupopen
2条回答

您可以尝试以下方法:

https://{username}:{password}@github.com/(company-name-here)/(repo-name-here)@compression-module

密码:这里可以是令牌或您的帐户密码

但建议使用令牌

您可以从这里创建一个令牌https://github.com/settings/tokens

转到设置>;开发者设置>;个人代币

因此,当我第一次创建python模块时,我使用了一个名为setuptools的第三方库,并且需要一些额外的配置

根据这一点,问题得以解决:) https://setuptools.readthedocs.io/en/latest/userguide/quickstart.html

相关问题 更多 >