pip install & uninstall recursively in non-interactive mode

A common issue on install is if there is a private repository dependency that has to be resolved and the key of the remote server has to be initially added.

Obtaining file://...
Collecting your_private_package@ git+ssh://...
  Cloning ssh://****@.../
  Running command git clone -q 'ssh://****@.../
The authenticity of host can't be established.
RSA key fingerprint is ...
Are you sure you want to continue connecting (yes/no)?

For this, ssh StrictHostKeyChecking would be temporarily set to no. This can be done at the host or user level at the risk of less security.


For uninstall, you can use the --yes or -y flag as described here: https://pip.pypa.io/en/stable/reference/pip_uninstall/?highlight=--yes

For installation, you can pass a yes | pip install -r requirements.txt as described here: python pip silent install

Hope this helps.


There are more interactive questions that expect other answers than "yes". For instance:

Directory /opt/services/spam/egg already exists, and is not a git clone.
What to do?  (i)gnore, (w)ipe, (b)ackup`

In such scenario I found calling echo "i" | pip install ... was sufficient.

Tags:

Python

Pip