How can I get `pip install`'s download progress? - download

Using pip install on some large package doesn't show any progress report while downloading.
Using the -v, --verbose option doesn't do it and there doesn't seem to be any other relevant option.

At least pip9 has -v option which prints debug msg during installation of the package.
$ pip --version
pip 9.0.1
Help:
$ pip install --help
..
..
-v, --verbose Give more output. Option is additive, and can be used up to 3 times.
Usage:
pip install -r requirements.txt -vvv

Seems that pip needs a --log argument to echo to the screen, e.g.:
$ pip -v --log /tmp/pip.log install $python_pkg --upgrade

Related

Installing with pip through xargs

I am trying to do some filtering on requirement.txt before installing individual python packages with pip (v3). I am stumped though why my usage of xargs here is messing up the pip command:
cat ./requirements.txt | xargs -I XXX pip --no-deps install XXX
...
Usage:
pip <command> [options]
no such option: --no-deps
...
If I just run pip --no-deps install SOMEPACKAGE then it works no problem. What's going on here please, and how do I fix it?
You should write pip install --no-deps instead of pip --no-deps install as --no-deps is an option of install and not viceversa.

Cannot cannot do pip install --no-deps in editable mode

How do I install a package with pip in editable mode and also not install its dependencies?
I tried both --no-deps and --no-dependencies:
$ pip install -e --no-deps .
ERROR: --no-deps is not a valid editable requirement. It should
either be a path to a local project or a VCS URL (beginning with svn+,
git+, hg+, or bzr+).
$ pip install -e --no-dependencies .
ERROR: --no-dependencies is not a valid editable requirement. It should
either be a path to a local project or a VCS URL (beginning with svn+,
git+, hg+, or bzr+).
but I always get an error.
Leaving out -e or --no-deps works:
$ pip install -e .
$ pip install --no-deps .
pip is a little quirky here. You have to have the --no-deps option before the -e option:
pip install --no-deps -e .
The docs technically list -e separately from the "options".

error during pip update

I am using pip in a cygwin environment under Win10.
$ pip --version
pip 9.0.1 from c:\python36\lib\site-packages (python 3.6)
I had coded a bash function molt to do python package maintenance in the past
molt () {
local i
for i in $(pip list | cut -d' ' -f1)
do
case $i in
pip|pywin32)
continue
;;
*)
pip install -qU $i
;;
esac
done
}
It worked until last week.
$ molt
Command "python setup.py egg_info" failed with error code 1 in C:\cygwin64\tmp\pip-build-lbe5xcu8\Package\
Usage:
pip install [options] <requirement specifier> [package-index-options] ...
pip install [options] -r <requirements file> [package-index-options] ...
pip install [options] [-e] <vcs project url> ...
pip install [options] [-e] <local project path> ...
pip install [options] <archive url/path> ...
no such option: --------------
I suspect pip must have changed but couldn't figure out what change broke the code. Please help.
It turned out that pip list returns
Package Version
-------------- -------
pip 9.0.1
setuptools 38.5.2
which leads pip install -qU Package -------------- according to the molt function, causing the error. The culprit is the new pip list output format (I forgot that I have changed the default legacy to columns a while ago). Restoring the default format option fixes the error, i.e.,
pip list --format=legacy

How to Install pip on Solaris 10?

I am new to python learning.I need to install pip on python2.6. From pip website, I downloaded "pip-9.0.1-py2.py3-none-any.whl" package but by which command I will install it.
I also tried the following option but not succeeded.
bash-3.2# apt install python-pip
apt: invalid flag: install
From OpenCSW:
pkgadd -d http://get.opencsw.org/now
/opt/csw/bin/pkgutil -U
/opt/csw/bin/pkgutil -y -i py_pip
/usr/sbin/pkgchk -L CSWpy-pip # list files
Don't forget to install python27 as well.

How to change pip3 command to be pip?

I uninstalled pip, and I installed pip3 instead. Now, I want to use pip3 by typing pip only. The reason is I am used to type pip only and every guide uses the pip command, so every time I want to copy and paste commands, I have to modify pip to pip3 which wastes time. When I type pip I have an error which is pip: command not found which means pip command is not taken. Is it possible to make pip points to pip3?
You can use pip3 using the alias pip by adding alias to your .bashrc file.
alias pip=pip3
or by adding a symlink named pip to your $PATH, which points to the pip3 binary.
If there is no ~/.bashrc in your home directory on macOS, inputting
alias pip=pip3
in your ~/.zprofile file has the same effect.
Rather than manually creating your own alias in bash and hoping this doesn't conflict with anything, most package managers should allow you to register the version you wish to use whilst maintaining dependencies.
For instance on Linux:
sudo update-alternatives --install /usr/bin/pip pip /usr/bin/pip3 1
Or on Mac (MacPorts):
port select --set pip pip3
Solution 1
Check which version pip is pointing to
pip --version
pip 18.0 from /usr/lib/python2.7/site-packages/pip (python 2.7)
If your pip is pointing to pip2, locate where is the pip "binary".
which pip
/usr/bin/pip
This is a simple python script:
cat /usr/bin/pip
#!/usr/bin/python2
# -*- coding: utf-8 -*-
import re
import sys
from pip._internal import main
if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
sys.exit(main())
So just change the shebang from #!/usr/bin/python2 to #!/usr/bin/python3.
Now pip is pointing to pip3.
pip --version
pip 18.0 from /usr/lib/python3.6/site-packages/pip (python 3.6)
Solution 2
Remove /usr/bin/pip make make a symbolic link from the wanted pip version to it instead.
sudo rm /usr/bin/pip
sudo ln -s /usr/bin/pip3.6 /usr/bin/pip
Since you uninstalled pip, this solution assumes you're only going to use pip3.
Open your terminal.
Create a simple link. To do that type:
sudo ln -s /usr/bin/pip3 /usr/bin/pip
Now when you type pip, it will invoke pip3.
Check that it worked by typing pip --version
pip --version
pip 9.0.1 from /usr/lib/python3/dist-packages (python 3.6)
You're all set!
You can install pip after install pip3 by the below command:
pip3 install --upgrade pip
after that:
~ pip --version
pip 20.0.2 from /usr/lib/python3/dist-packages/pip (python 3.8)
You can write pip for pip3 after changing bashrc file in the home directory.
In mac -
Open bashrc file -
vim ~/.bashrc
Add this line at the end of the file -
alias pip="pip3"
Close the file. Don't forget to source this file in the terminal by
source ~/.bashrc
You are good to go. Now, whenever you will use pip in any command. it will be interpreted as pip3
You can check it by running the command -
pip --version
Pip is installed in /usr/bin/. If you don't have pip at all, I would suggest to install pip3 only. Make sure you don't need older version.
You can check available pip versions using following command.
ls /usr/bin/pip*
If you have multiple pip you need to prioritize your pip versions. I had only pip3 so I add it to the first priority. You can use following command and it is done.
sudo update-alternatives --install /usr/bin/pip pip /usr/bin/pip3 1
You will get output as :
update-alternatives: using /usr/bin/pip3 to provide /usr/bin/pip (pip) in auto mode
Test now:
pip --version
You will get:
pip 18.1 from /usr/lib/python3/dist-packages/pip (python 3.7)
If you have other version for python2.7, you can use same update command and change last digit 1 to 2. This will make it second priority.
I believe one shouldn't do such a thing. Actually I would argue it's even better to not use the pip, pip3, etc. scripts ever. Instead one should always prefer the more explicit and surefire way of using pip's executable module for one specific Python interpreter:
path/to/pythonX.Y -m pip somecommand
References:
https://snarky.ca/why-you-should-use-python-m-pip/
https://snarky.ca/a-quick-and-dirty-guide-on-how-to-install-packages-for-python/
This can be done by simply creating an alias for the command.
To create an alias just type
$alias new_command="existing_command"
In your case,
$alias pip="pip3"
Although this isn't permanent. OT make it permanent edit your bashrc file
$ vim ~/.bashrc
an to the end of it append the line.
$alias pip="pip3"
It depends on how you manage your python versions (system, brew, pyenv, ...) and which python installation you are currently using.
For example if you use brew then creating a simlink is a good option:
ln -s -f /usr/local/bin/pip3 /usr/local/bin/pip
validate that pip uses the correct version:
which pip
will give you
/usr/local/bin/pip
Copy the pip3 file and rename as pip:
sudo cp /usr/bin/pip3 /usr/bin/pip
pip --version
and
pip3 --version
Works now.

Resources