Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python pip - ignored .netrc and pip.conf files

Tags:

python

pip

I want to install packages with pip and not be asked for the credentials and not to store credentials in pip.conf file This is something which is explained previously here Credentials in pip.conf for private PyPI

So the steps I did. in /home/jenkins folder I create .netrc file:

machine https://artifactory.domain.dev
    login username1
    password password1

in /home/jenkins folder I create pip.conf file:

[global]
index-url = http://artifactory.domain.dev/artifactory/api/pypi/pypi-remote/simple

I create a virtualenv and try to install package:

If I specify URL in the command I am prompted for credentials:

python -m pip install python-cards -v -i https://artifactory.domain.dev/artifactory/api/pypi/pypi-remote/simple
User for artifactory.domain.dev:

If I do not specify -i property then I see everything is installed but from the pypi.org which I shouldn't do that in that way (because on customer servers we will not have access to internet).

 python -m pip install python-cards
Using cached https://files.pythonhosted.org/

It seems like both of my files .netrc and pip.conf are being ignored. Why? Did I set up something wrong?

Thank you!

like image 314
AndreyS Avatar asked Mar 04 '26 11:03

AndreyS


1 Answers

Have a look here where to place the pip.conf: https://pip.pypa.io/en/stable/topics/configuration/#location

Probably you want to place it here: /home/jenkins/.config/pip/pip.conf

I do believe that the .netrc should be directly in the home directory, but check that this file is owned by the user that is executing pip. Replace $USER with the correct user (jenkins?) if it is not the current user

chown $USER ~/.netrc 
chmod 0600
like image 191
Teije Avatar answered Mar 07 '26 00:03

Teije