Python Forum

Full Version: How to detect third party packages used in the code
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi,
I really do not know how to do this.
Is there any way to detect what are the third party packages used when we are using code developed by others. Not by eye-ball check (I want auto-detect).

The example code below: I imported openpyxl, pandas
I want to list them.

import pandas as pd
df_hyper=pd.read_excel(r'D:\Mekala_Backupdata\PythonCodes\hyperlink.xlsx',escape=False)
df_hyper.to_html('mylink.html',escape=False,index=False)

import openpyxl

wb = openpyxl.load_workbook(r'D:\Mekala_Backupdata\PythonCodes\hyperlink.xlsx')
ws = wb.get_sheet_by_name('Hyperlinks')
print(ws.cell(row=2, column=1).hyperlink.target)
The standard way for a project to list its third party dependencies is to use a requirements file.
I want to list down automatically when reading other's code and without going through the code. Can we develop any python code to detect such functionality?
Why? If projects are using the requirements file, why do you need that?
Because I want to list all packages, and check their versions in my local machine.
Is the project not using a requirements file? It's highly unlikely, given that is the standard way to list dependencies.

If you want to know what you have installed, then either pip list, or pip freeze will do the job (the latter gives the output in the same format as is used in requirements files).