I'm having trouble reaching a nexus server that we're using to store custom python packages. I've been told to change the settings in both my ~/.pypirc
file and the ~/.pip/pip.conf
file.
What's the difference between those two files in how they're used? It seems like the pip install -r requirements.txt
command refers to the pip.conf
file, and then the fields within the pip.conf
file requires looking up the pypirc file?
Example pip.conf file:
[global]
index = https://user:[email protected]/somerepo/pypi-group/pypi
index-url = index = https://user:[email protected]/somerepo/pypi-group/simple
Example pypirc file:
[distutils]
index-servers =
pypi
nexus
[pypi]
repository: https://pypi.org/pypi
username: abc
password: def
[nexus]
repository: https://someurl.com/somerepo/pypi-internal
username: someuser
password: somepassword
Also, what's the difference between index and index-url in the pip.conf file?
A . pypirc file allows you to define the configuration for package indexes (referred to here as “repositories”), so that you don't have to enter the URL, username, or password whenever you upload a package with twine or flit.
PIP is a package manager for Python packages, or modules if you like. Note: If you have Python version 3.4 or later, PIP is included by default.
This file must be placed in $HOME/. pypirc for pip/twine to use it. Keep in mind, pypi.org and test.pypi.org are not integrated, so you'll need to have a separate account created on each site. One thing to notice above is that the [pypi] section does not have repository configured, but the testpypi section does.
pip is the de facto package manager in the Python world. It can install packages from many sources, but PyPI is the primary package source where it's used. When installing packages, pip will first resolve the dependencies, check if they are already installed on the system, and, if not, install them.
.pypirc
is a file standard used by multiple tools, but not by pip
. For example, the easy_install
tool reads that file, as does twine
. It contains configuration on how to access specific PyPI index servers when publishing a package.
pip.conf
on the other hand is only used by the pip
tool, and pip
never publishes packages, it downloads packages from them. As such, it never looks at the .pypirc
file.
If you are not publishing packages, you don't need a .pypirc
file. You can't use it to configure index servers for pip
.
As for the --index-url
and --index
switches, these are used for different pip
commands.
--index-url
is a common switch among several pip commands that deal with installing packages (pip install
, pip download
, pip list
, and pip wheel
), where it is part of a group of switches (together with --extra-index-url
, --no-index
, --find-links
and --process-dependency-links
and a few deprecated switches) that all together configure how package discovery works. The URL must point to a PEP 503 Simple Repository API location, the default is https://pypi.org/simple
.
--index
is only used by pip search
; it only needs this one piece of information. It is named separately because it should point to the public search web interface, not the simple repository! For https://pypi.org, that's https://pypi.org/pypi
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With