How to know which version in use of a particular package is installed via Pip?

Asked

Viewed 12,261 times

4

I am starting programming in python and have tried to use best practices: virtualenv, Pip, etc. One of the packages I’ve been using (Pelican) has different help pages for each version. How do I know which version I’m using? I installed it with the command:

pip install pelican

But I no longer remember which version was downloaded. It is possible to see?

Thank you!

4 answers

4

As I wrote the question, I remembered the answer:

pip freeze

It returns the following:

pelican==3.5.0

I had used the command to create the.txt file, which is another place where you can look.

3

3

To see the installed version of a specific package use:

pip show pelican

this command will show the installed version and other package information.

To list the version of all installed packages use:

pip freeze

This command will produce an output like this:

blinker==1.3
docutils==0.12
feedgenerator==1.7
Jinja2==2.7.3
MarkupSafe==0.23
pelican==3.5.0
Pygments==2.0.2
python-dateutil==2.4.2
pytz==2015.4
six==1.9.0
Unidecode==0.4.18

It is common to use Pip Freeze to generate a Requirements.txt file, since the format generated by the output is compatible with Pip install -r

It is also worth mentioning the command

pip list

Which produces an output as the example below:

blinker (1.3)
docutils (0.12)
feedgenerator (1.7)
Jinja2 (2.7.3)
MarkupSafe (0.23)
pelican (3.5.0)
pip (7.0.3)
Pygments (2.0.2)
python-dateutil (2.4.2)
pytz (2015.4)
setuptools (17.1.1)
six (1.9.0)
Unidecode (0.4.18)

Which is not so different from Pip Freeze, its advantage is to use along with the -o option:

pip list -o

Which will list only the pactoes that have updates available along with the installed version and the available version, in the format below:

pelican (Current: 3.4.0 Latest: 3.5.0 [wheel])

1

It is interesting that you store in a file the list of all installed packages of your project, as you already know using the command pip freeze the packages and their versions are displayed.

To save direct to a file just use:

pip freeze > requerimentos.txt

To install the listed packages just use the command:

pip install -r requirimentos.txt

Browser other questions tagged

You are not signed in. Login or sign up in order to post.