-1

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?

Adithya
  • 19
  • 6
  • I just rolled back your edit as it changes the question to much. The already existing answers wouldn't be valid any more. You might want to ask a new question which specifically asks for at what date a module was installed. – user1251007 Mar 07 '19 at 22:01
  • "when" usually means "at what date or time", but the users understood it as "if", so the answers aren't valid for my question. – Adithya Mar 09 '19 at 03:11
  • I think it's a language problem, I totally understand your intention. However, as far as I can tell, If your intention is "at what time and date" you should at least have written "when **was** a module installed?" I would advise editing "when" into "if" to make this question clear and fit to the answers. And again, feel free to ask a new question. – user1251007 Mar 09 '19 at 06:21

3 Answers3

1

pip freeze | grep <module> should work. If you have Anaconda, conda list also gives you the modules.

busybear
  • 10,194
  • 1
  • 25
  • 42
  • pip: command not found. I know that pip freeze only displays the list of modules with their version numbers. I want to know at what date and time a module is installed. – Adithya Mar 07 '19 at 01:54
  • Typically pip comes with python. Maybe try `python -m pip freeze`? You could also try just importing the module with `python -c "import "` and look for an `ImportError`. – busybear Mar 07 '19 at 02:00
  • Did you meant that pip freeze displays all the modules installed with date and time? I'm able to import the module without any error. I just need to know at what date and time it got installed. – Adithya Mar 07 '19 at 02:05
  • I see what you are asking now with your edited post. I've commented above. – busybear Mar 07 '19 at 02:07
0
pip freeze | grep <moduleName>
Hasee Amarathunga
  • 1,901
  • 12
  • 17
0

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.

Community
  • 1
  • 1
user1251007
  • 15,891
  • 14
  • 50
  • 76