As a part of my bash script, I want to install and uninstall pip dependencies that I have their names in a file in a non-interactive mode. I was able to search around and find these commands:
pip3 uninstall --yes -r host-requirements.txt
pip3 install --no-input -r host-requirements.txt
I wasn't able to find --yes
& --no-input
options in the help doc of pip, and I'm not sure if they are officially supported.
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.
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.
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