1

I Got this small question in my mind. while we are installing any third-party modules. some other modules will also get installed along with It. How To Find What All Additional Modules Are Installed. For Example this code.

from gtts import gTTS 

While Install this module some other modules like "six" Are Getting Installed.

How to Find What Extra Modules Are Getting Installed while I install gtts or any other modules

Belgin Android
  • 309
  • 5
  • 19
  • Does this answer your question? [How to list imported modules?](https://stackoverflow.com/questions/4858100/how-to-list-imported-modules) – Random Davis Sep 24 '20 at 15:11
  • @RandomDavis Thanks For The Answer Sir, But My Question is To Find Out What Are The Extra Modules That Are Getting Installed While I run `pip install gtts` – Belgin Android Sep 24 '20 at 15:14
  • A potential problem here is with shared modules. There could some modules used by `gtts` that were already imported by earlier imports. – ekhumoro Sep 24 '20 at 15:22
  • @ekhumoro Yes Sir , Is There Any Possible Way To Find Out ? – Belgin Android Sep 24 '20 at 15:23
  • Can I ask why you need this information? What actual problem are you trying to solve? – ekhumoro Sep 24 '20 at 15:25
  • No, you can't find it out. Not if you take in account what you can do when you use [`importlib`](https://docs.python.org/3/library/importlib.html). – Matthias Sep 24 '20 at 15:25
  • @ekhumoro I Just Want To Know What Other modules are being installed while I Install a particular module using pip ... For Example There is a module named text-to-speech but inside the module it uses gtts ... so why cant i directly use gtts . So for finding that kind of modules – Belgin Android Sep 24 '20 at 15:29

1 Answers1

1

You can get a list of modules installed for your program using pip freeze

pip freeze > requirements.txt

This requirements.txt list all the package required by your program.

  • Thank You Let Me Give It A Try – Belgin Android Sep 24 '20 at 15:15
  • Thanks For The Answer Sir, But My Question is To Find Out What Are The Extra Modules That Are Getting Installed While I run `pip install gtts` – Belgin Android Sep 24 '20 at 15:18
  • 1
    Ya, I understand your question, give it a try. 1. create a virtual environment, activate it and install just flask 2. Now create requirements.txt file, check out this file. 3. you will get `click==7.1.2 Flask==1.1.2 itsdangerous==1.1.0 Jinja2==2.11.2 MarkupSafe==1.1.1 Werkzeug==1.0.1` – Bipul singh kashyap Sep 24 '20 at 15:26
  • @BelginAndroid These extra packages are not installed by you, it's installed by flask if you check terminal during flask installation. – Bipul singh kashyap Sep 24 '20 at 15:29
  • Thank You So Much Let Me Try This Out : ) – Belgin Android Sep 24 '20 at 15:31
  • Ya Sir, So We Should Create A Separate Virtual Environment for each module we are testing? like once we tested for flask . then we need to create another virtual env for testing another module ? – Belgin Android Sep 24 '20 at 15:33
  • @BelginAndroid Look if you are working on a project then it's good practice to create a separate virtual environment for that project because of python or its packages are not stable. – Bipul singh kashyap Sep 24 '20 at 15:35
  • Yes Sir, You Are Right . But my question is as you said while running in virtual env . We can easily list out all the modules that are installed by flask . But If we install two more modules like `pip install flask` and `pip install gtts` in the same virtual env . then if i run `pip freeze > requirements.txt` Then It Will list out all the modules installed by both right sir ? – Belgin Android Sep 24 '20 at 15:43
  • Yes, It will create a list of all the installed modules. This is the standard way to create requirements for our project for further installation of all the required package. – Bipul singh kashyap Sep 24 '20 at 15:46
  • Thank You, Sir. For Your Time. It Was Really Helpfull – Belgin Android Sep 24 '20 at 15:51
  • Must it be done in a virtual environment for the command to work properly? – Peter Mortensen Sep 25 '20 at 13:10
  • It's not necessary to install or run python packages or modules in a virtual environment. It's an isolated environment, let's suppose you are working with some library which only works on python3.6 but Now 3.10 is available if you upgrade your python to 3.10 your program stops working but if you have a virtual environment this update will not affect your previous program. – Bipul singh kashyap Sep 25 '20 at 15:05