简体   繁体   中英

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

This question is like pip is not using extra index url defined in pip.conf , but there was no solution to it. I'm giving more details in this question:

I have a ~/.config/pip/pip.conf file with the following lines:

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

And this is the output of pip3 config list :

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

When I try to install a package that exists in mypypi (in a brand new folder), it throws the following error:

[~/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

However, it I remove the pip.conf file and use the corresponding environment variables instead, it works with no problem. That is, if I define these environment variables:

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

This is the result in a brand new folder:

~/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.

I can't figure out what it is I'm doing wrong with the pip.conf file.

It works as well if I install the package like this: pipenv install --extra-index-url http://mypypi.hopto.org:9111 localutils-cprietom

Try to put this to your Pipfile

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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