繁体   English   中英

在 pip.conf 文件中使用时,extra-index-url 未正确使用

[英]extra-index-url is not getting used properly when used in pip.conf file

这个问题就像pip is not using extra index url defined in pip.conf ,但没有解决办法。 我在这个问题中提供了更多细节:

我有一个包含以下行的~/.config/pip/pip.conf文件:

[global]
trusted-host = mypypi.hopto.org
extra-index-url = http://mypypi.hopto.org:9111

这是pip3 config list的 output:

[~/tmp8]$ pip3 config list                      
global.extra-index-url='http://mypypi.hopto.org:9111'
global.trusted-host='mypypi.hopto.org'
[~/tmp8]$ 

当我尝试安装 mypypi 中存在的 package(在一个全新的文件夹中)时,它会抛出以下错误:

[~/tmp8]$ pipenv install localutils-cprietom
Creating a virtualenv for this project...
Pipfile: /home/cprietom/tmp8/Pipfile
Using /usr/bin/python3.8 (3.8.10) to create virtualenv...
⠹ Creating virtual environment...created virtual environment CPython3.8.10.final.0-64 in 96ms
  creator CPython3Posix(dest=/home/cprietom/.local/share/virtualenvs/tmp8-12QnL_WT, clear=False, no_vcs_ignore=False, global=False)
  seeder FromAppData(download=False, pip=bundle, setuptools=bundle, wheel=bundle, via=copy, app_data_dir=/home/cprietom/.local/share/virtualenv)
    added seed packages: pip==22.0.4, setuptools==60.9.3, wheel==0.37.1
  activators BashActivator,CShellActivator,FishActivator,NushellActivator,PowerShellActivator,PythonActivator

✔ Successfully created virtual environment! 
Virtualenv location: /home/cprietom/.local/share/virtualenvs/tmp8-12QnL_WT
Creating a Pipfile for this project...
Installing localutils-cprietom...
Adding localutils-cprietom to Pipfile's [packages]...
✔ Installation Succeeded 
Pipfile.lock not found, creating...
Locking [dev-packages] dependencies...
Locking [packages] dependencies...
Building requirements...
Resolving dependencies...
✘ Locking Failed! 

CRITICAL:pipenv.patched.notpip._internal.resolution.resolvelib.factory:Could not find a version that satisfies the requirement localutils-cprietom (from versions: none)
[ResolutionFailure]:   File "/home/cprietom/.local/lib/python3.8/site-packages/pipenv/resolver.py", line 743, in _main
[ResolutionFailure]:       resolve_packages(pre, clear, verbose, system, write, requirements_dir, packages, dev)
[ResolutionFailure]:   File "/home/cprietom/.local/lib/python3.8/site-packages/pipenv/resolver.py", line 704, in resolve_packages
[ResolutionFailure]:       results, resolver = resolve(
[ResolutionFailure]:   File "/home/cprietom/.local/lib/python3.8/site-packages/pipenv/resolver.py", line 685, in resolve
[ResolutionFailure]:       return resolve_deps(
[ResolutionFailure]:   File "/home/cprietom/.local/lib/python3.8/site-packages/pipenv/utils.py", line 1377, in resolve_deps
[ResolutionFailure]:       results, hashes, markers_lookup, resolver, skipped = actually_resolve_deps(
[ResolutionFailure]:   File "/home/cprietom/.local/lib/python3.8/site-packages/pipenv/utils.py", line 1106, in actually_resolve_deps
[ResolutionFailure]:       resolver.resolve()
[ResolutionFailure]:   File "/home/cprietom/.local/lib/python3.8/site-packages/pipenv/utils.py", line 884, in resolve
[ResolutionFailure]:       raise ResolutionFailure(message=str(e))
[pipenv.exceptions.ResolutionFailure]: Warning: Your dependencies could not be resolved. You likely have a mismatch in your sub-dependencies.
  You can use $ pipenv install --skip-lock to bypass this mechanism, then run $ pipenv graph to inspect the situation.
  Hint: try $ pipenv lock --pre if it is a pre-release dependency.
ERROR: No matching distribution found for localutils-cprietom

但是,如果我删除 pip.conf 文件并改用相应的环境变量,它就可以正常工作。 也就是说,如果我定义这些环境变量:

[~/tmp5]$ echo $PIP_EXTRA_INDEX_URL
http://mypypi.hopto.org:9111
[~/tmp5]$ echo $PIP_TRUSTED_HOST                     
mypypi.hopto.org
[~/tmp5]$ 

这是一个全新文件夹中的结果:

~/tmp5]$ pipenv install localutils-cprietom
Creating a virtualenv for this project...
Pipfile: /home/cprietom/tmp5/Pipfile
Using /usr/bin/python3.8 (3.8.10) to create virtualenv...
⠹ Creating virtual environment...created virtual environment CPython3.8.10.final.0-64 in 98ms
  creator CPython3Posix(dest=/home/cprietom/.local/share/virtualenvs/tmp5-j3c38XGg, clear=False, no_vcs_ignore=False, global=False)
  seeder FromAppData(download=False, pip=bundle, setuptools=bundle, wheel=bundle, via=copy, app_data_dir=/home/cprietom/.local/share/virtualenv)
    added seed packages: pip==22.0.4, setuptools==60.9.3, wheel==0.37.1
  activators BashActivator,CShellActivator,FishActivator,NushellActivator,PowerShellActivator,PythonActivator

✔ Successfully created virtual environment! 
Virtualenv location: /home/cprietom/.local/share/virtualenvs/tmp5-j3c38XGg
Creating a Pipfile for this project...
Installing localutils-cprietom...
Adding localutils-cprietom to Pipfile's [packages]...
✔ Installation Succeeded 
Pipfile.lock not found, creating...
Locking [dev-packages] dependencies...
Locking [packages] dependencies...
Building requirements...
Resolving dependencies...
✔ Success! 
Updated Pipfile.lock (bbb00d)!
Installing dependencies from Pipfile.lock (bbb00d)...
  🐍   ▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉ 0/0 — 00:00:00
To activate this project's virtualenv, run pipenv shell.
Alternatively, run a command inside the virtualenv with pipenv run.

我无法弄清楚 pip.conf 文件我做错了什么。

如果我像这样安装 package,它也能正常工作: pipenv install --extra-index-url http://mypypi.hopto.org:9111 localutils-cprietom

尝试将其放入您的 Pipfile

[[source]]
url = "http://mypypi.hopto.org:9111"
verify_ssl = true
name = "hopto"

[packages]
localutils-cprietom = {version = "*", index="hopto"}

暂无
暂无

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

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