I can only login as a regular user on Linux, and a superuser has installed a module.
How to find out if a module is installed?
I can only login as a regular user on Linux, and a superuser has installed a module.
How to find out if a module is installed?
pip freeze | grep <module>
should work. If you have Anaconda, conda list
also gives you the modules.
Using pure python on the command line:
python -c "import desiredModule"
If the desired module is already installed, simply an empty line is returned. If the module is not installed, an ImportError
is raised.
This solution has the bonus of working on all different python versions, while the pip approach does only work when pip is installed (which is per default on newer version of python.)
Using pip, from the documentation:
pip list
List installed packages, including editables.
Packages are listed in a case-insensitive sorted order.
pip freeze
Output installed packages in requirements format.
packages are listed in a case-insensitive sorted order.
Please refer to this question for a detailed explanation of the differences of freeze
and list
.