簡體   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