snippetpythonCriticalCanonical
How do I check the versions of Python modules?
Viewed 0 times
howcheckversionsthemodulespython
Problem
I installed the Python modules
How do I check their versions from the command line?
construct and statlib using setuptools:sudo apt-get install python-setuptools
sudo easy_install statlib
sudo easy_install constructHow do I check their versions from the command line?
Solution
Use
With pip, list all installed packages and their versions via:
On most Linux systems, you can pipe this to
Linux:
lxml==2.3
Windows:
lxml==2.3
For an individual module, you can try the
Traceback (most recent call last):
File "", line 1, in
AttributeError: 'module' object has no attribute '__version__'
Lastly, as the commands in your question are prefixed with
pip instead of easy_install.With pip, list all installed packages and their versions via:
pip freeze
On most Linux systems, you can pipe this to
grep (or findstr on Windows) to find the row for the particular package you're interested in.Linux:
pip freeze | grep lxml
lxml==2.3
Windows:
pip freeze | findstr lxml
lxml==2.3
For an individual module, you can try the
__version__ attribute. However, there are modules without it:python -c "import requests; print(requests.__version__)"
2.14.2
python -c "import lxml; print(lxml.__version__)"
Traceback (most recent call last):
File "", line 1, in
AttributeError: 'module' object has no attribute '__version__'
Lastly, as the commands in your question are prefixed with
sudo, it appears you're installing to the global python environment. I strongly advise to take look into Python virtual environment managers, for example virtualenvwrapper.Context
Stack Overflow Q#20180543, score: 1178
Revisions (0)
No revisions yet.