# Parses all imports and the imports of the imports of a py file into a Pandas DataFrame using pipdeptree/pipreqs/pip
## pip install pip2df
### Tested against Windows 10 / Python 3.10 / Anaconda
```python
# The Python file you want to get the imports from
# "C:\ProgramData\anaconda3\envs\adda\stra6.py" in this case
from win10ctypestoast import show_toast
show_toast(
title="Title",
message="Message",
icon=r"C:\Users\hansc\Pictures\numberresults.png",
duration=1,
repeat=2,
pause=2,
threaded=False,
)
# Create a new file (Console works as well) and use this code:
# The first time you use this module, you have to parse all modules in the env
from pip2df import ImportFetcher
cf = ( # Parsing 150 packages takes around 5 minutes.
ImportFetcher()
.get_all_modules_in_env(
ignore_packages=(
"ipython",
"pip",
"zipp",
"docutils",
"black",
"pipreqs",
"readme-renderer",
"rich",
"twine",
"keyring",
"importlib-metadata",
)
)
.save_all_modules_dataframe("f:\\saveallimports.pkl") # Since you are probably not installing every day a new package, you can save the parsing results and load them later on
)
cf.load_all_modules_dataframe('f:\\saveallimports.pkl') # Save the parsing results
print(cf.df) # Shows all modules in the env
fileimports = cf.get_imports_from_py_file(
r"C:\ProgramData\anaconda3\envs\adda\stra6.py"
)
print(fileimports.to_string())
# Output
package_name deps folders Version Summary Home-page Author Author-email License Location Requires Required-by pipreqs import_level
116 win10ctypestoast ((Pillow, None), (pystray, None)) C:\ProgramData\anaconda3\envs\adda\lib\site-packages\win10ctypestoast 0.10 Windows-10-Toast-Notifications without pywin32 dependency https://github.com/hansalemaos/win10ctypestoast Johannes Fischer <aulasparticularesdealemaosp@gmail.com> MIT c:\programdata\anaconda3\envs\adda\lib\site-packages Pillow, pystray ((Pillow, >=9.5.0), (pystray, >=0.19.4)) 0
76 Pillow () C:\ProgramData\anaconda3\envs\adda\lib\site-packages\PIL 9.4.0 Python Imaging Library (Fork) https://python-pillow.org Alex Clark (PIL Fork Author) aclark@python-pillow.org HPND c:\programdata\anaconda3\envs\adda\lib\site-packages convpic2ico, pystray, win10ctypestoast ((cffi, >=1.15.1), (defusedxml, >=0.7.1), (ipython, >=8.12.0), (numpy, >=1.24.2), (olefile, >=0.46), (packaging, >=23.0), (PyQt5, >=5.15.9), (PyQt6, >=6.4.2), (PySide2, >=5.15.2.1), (PySide6, >=6.5.0)) 1
88 pystray ((Pillow, None), (six, None)) C:\ProgramData\anaconda3\envs\adda\lib\site-packages\pystray 0.19.4 Provides systray integration https://github.com/moses-palmer/pystray Moses Palmér moses.palmer@gmail.com LGPLv3 c:\programdata\anaconda3\envs\adda\lib\site-packages Pillow, six win10ctypestoast ((AppKit, >=0.2.8), (Foundation, >=0.1.0a0.dev1), (Pillow, >=9.5.0), (six, >=1.16.0), (Xlib, >=0.21)) 1
66 numpy () C:\ProgramData\anaconda3\envs\adda\lib\site-packages\numpy 1.24.2 Fundamental package for array computing in Python https://www.numpy.org Travis E. Oliphant et al. BSD-3-Clause c:\programdata\anaconda3\envs\adda\lib\site-packages a-cv-imwrite-imread-plus, a-pandas-ex-fastloc, a-pandas-ex-numexpr, a-pandas-ex-plode-tool, check-if-nan, group-and-iter-everything, locate-pixelcolor, npfastsortcpp, numexpr, opencv-python, pandas, pdmemedit, PrettyColorPrinter ((charset_normalizer, >=3.1.0), (Cython, >=0.29.33), (genapi, >=0.0.8), (hypothesis, >=6.70.2), (mtrand, >=0.1), (mypy, >=1.1.1), (nose, >=1.3.7), (numarray, >=1.5.1), (Numeric, >=24.2), (pickle5, >=0.0.12), (psutil, >=5.9.4), (PyInstaller, >=5.9.0), (pytest, >=7.2.2), (pytz, >=2023.2), (scipy, >=1.10.1), (setuptools, >=65.6.3), (threadpoolctl, >=3.1.0), (typing_extensions, >=4.5.0)) 2
98 six () <NA> 1.16.0 Python 2 and 3 compatibility utilities https://github.com/benjaminp/six Benjamin Peterson benjamin@python.org MIT c:\programdata\anaconda3\envs\adda\lib\site-packages asttokens, bleach, pystray, python-dateutil <NA> 2
14 charset-normalizer () C:\ProgramData\anaconda3\envs\adda\lib\site-packages\charset_normalizer 3.1.0 The Real First Universal Charset Detector. Open, modern and actively maintained alternative to Chardet. https://github.com/Ousret/charset_normalizer Ahmed TAHRI ahmed.tahri@cloudnursery.dev MIT c:\programdata\anaconda3\envs\adda\lib\site-packages requests () 3
21 Cython () C:\ProgramData\anaconda3\envs\adda\lib\site-packages\Cython 0.29.33 The Cython compiler for writing C extensions for the Python language. http://cython.org/ Robert Bradshaw, Stefan Behnel, Dag Seljebotn, Greg Ewing, et al. cython-devel@python.org Apache c:\programdata\anaconda3\envs\adda\lib\site-packages npfastsortcpp ((cElementTree, >=1.0.2-20050302), (coverage, >=7.2.2), (Cython, >=0.29.33), (elementtree, >=1.2.6-20050316), (ipython, >=8.12.0), (lxml, >=4.9.2), (Parser, >=0.1), (Pygments, >=2.14.0), (pythran, >=0.12.1), (runtests, >=0.0.28), (setuptools, >=65.6.3)) 3
83 psutil () C:\ProgramData\anaconda3\envs\adda\lib\site-packages\psutil 5.9.4 Cross-platform lib for process and system monitoring in Python. https://github.com/giampaolo/psutil Giampaolo Rodola g.rodola@gmail.com BSD-3-Clause c:\programdata\anaconda3\envs\adda\lib\site-packages pdmemedit, subprocess-print-and-capture ((concurrencytest, >=0.1.2), (mock, >=5.0.1), (pip, >=23.0.1), (wheel, >=0.38.4), (wmi, >=1.5.1)) 3
90 pytz () C:\ProgramData\anaconda3\envs\adda\lib\site-packages\pytz 2023.2 World timezone definitions, modern and historical http://pythonhosted.org/pytz Stuart Bishop stuart@stuartbishop.net MIT c:\programdata\anaconda3\envs\adda\lib\site-packages pandas ((sets, >=0.3.2), (setuptools, >=65.6.3)) 3
96 setuptools () C:\ProgramData\anaconda3\envs\adda\lib\site-packages\setuptools 65.6.3 Easily download, build, install, upgrade, and uninstall Python packages https://github.com/pypa/setuptools Python Packaging Authority distutils-sig@python.org c:\programdata\anaconda3\envs\adda\lib\site-packages npfastsortcpp ((Cython, >=0.29.33), (dl, >=0.1.0), (docutils, >=0.19), (Jinja2, >=3.1.2), (numpy, >=1.24.2), (railroad, >=0.5.0), (setuptools, >=65.6.3), (trove_classifiers, >=2023.3.9)) 3
86 Pygments () C:\ProgramData\anaconda3\envs\adda\lib\site-packages\pygments 2.14.0 Pygments is a syntax highlighting package written in Python. https://pygments.org/ Georg Brandl georg@python.org BSD-2-Clause c:\programdata\anaconda3\envs\adda\lib\site-packages ipython, readme-renderer, rich ((chardet, >=5.1.0), (colorama, >=0.4.6), (docutils, >=0.19), (importlib_metadata, >=6.1.0), (Pillow, >=9.5.0), (setuptools, >=65.6.3), (Sphinx, >=6.1.3)) 4
115 wheel () C:\ProgramData\anaconda3\envs\adda\lib\site-packages\wheel 0.38.4 A built-package format for Python https://github.com/pypa/wheel Daniel Holth dholth@fastmail.fm MIT c:\programdata\anaconda3\envs\adda\lib\site-packages ((setuptools, >=65.6.3),) 4
16 colorama () C:\ProgramData\anaconda3\envs\adda\lib\site-packages\colorama 0.4.6 Cross-platform colored terminal text. Jonathan Hartley <tartley@tartley.com> c:\programdata\anaconda3\envs\adda\lib\site-packages click, ipython ((contextlib2, >=21.6.0), (mock, >=5.0.1)) 5
```
Raw data
{
"_id": null,
"home_page": "https://github.com/hansalemaos/pip2df",
"name": "pip2df",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "PIP,pipreqs,piptree,parse,imports",
"author": "Johannes Fischer",
"author_email": "<aulasparticularesdealemaosp@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/a9/2f/b069ab9411805c7258331e26e417694526747f80070e774adadb042d8108/pip2df-0.11.tar.gz",
"platform": null,
"description": "\r\n# Parses all imports and the imports of the imports of a py file into a Pandas DataFrame using pipdeptree/pipreqs/pip\r\n\r\n\r\n\r\n## pip install pip2df\r\n\r\n\r\n\r\n### Tested against Windows 10 / Python 3.10 / Anaconda \r\n\r\n\r\n\r\n```python\r\n\r\n# The Python file you want to get the imports from \r\n\r\n# \"C:\\ProgramData\\anaconda3\\envs\\adda\\stra6.py\" in this case \r\n\r\nfrom win10ctypestoast import show_toast\r\n\r\n\r\n\r\nshow_toast(\r\n\r\n title=\"Title\",\r\n\r\n message=\"Message\",\r\n\r\n icon=r\"C:\\Users\\hansc\\Pictures\\numberresults.png\",\r\n\r\n duration=1,\r\n\r\n repeat=2,\r\n\r\n pause=2,\r\n\r\n threaded=False,\r\n\r\n)\r\n\r\n\r\n\r\n\r\n\r\n# Create a new file (Console works as well) and use this code:\r\n\r\n# The first time you use this module, you have to parse all modules in the env\r\n\r\nfrom pip2df import ImportFetcher\r\n\r\ncf = ( # Parsing 150 packages takes around 5 minutes.\r\n\r\n ImportFetcher()\r\n\r\n .get_all_modules_in_env(\r\n\r\n ignore_packages=(\r\n\r\n \"ipython\",\r\n\r\n \"pip\",\r\n\r\n \"zipp\",\r\n\r\n \"docutils\",\r\n\r\n \"black\",\r\n\r\n \"pipreqs\",\r\n\r\n \"readme-renderer\",\r\n\r\n \"rich\",\r\n\r\n \"twine\",\r\n\r\n \"keyring\",\r\n\r\n \"importlib-metadata\",\r\n\r\n )\r\n\r\n )\r\n\r\n .save_all_modules_dataframe(\"f:\\\\saveallimports.pkl\") # Since you are probably not installing every day a new package, you can save the parsing results and load them later on\r\n\r\n)\r\n\r\ncf.load_all_modules_dataframe('f:\\\\saveallimports.pkl') # Save the parsing results \r\n\r\nprint(cf.df) # Shows all modules in the env \r\n\r\nfileimports = cf.get_imports_from_py_file(\r\n\r\n r\"C:\\ProgramData\\anaconda3\\envs\\adda\\stra6.py\" \r\n\r\n) \r\n\r\nprint(fileimports.to_string())\r\n\r\n\r\n\r\n\r\n\r\n# Output \r\n\r\n package_name deps folders Version Summary Home-page Author Author-email License Location Requires Required-by pipreqs import_level\r\n\r\n116 win10ctypestoast ((Pillow, None), (pystray, None)) C:\\ProgramData\\anaconda3\\envs\\adda\\lib\\site-packages\\win10ctypestoast 0.10 Windows-10-Toast-Notifications without pywin32 dependency https://github.com/hansalemaos/win10ctypestoast Johannes Fischer <aulasparticularesdealemaosp@gmail.com> MIT c:\\programdata\\anaconda3\\envs\\adda\\lib\\site-packages Pillow, pystray ((Pillow, >=9.5.0), (pystray, >=0.19.4)) 0\r\n\r\n76 Pillow () C:\\ProgramData\\anaconda3\\envs\\adda\\lib\\site-packages\\PIL 9.4.0 Python Imaging Library (Fork) https://python-pillow.org Alex Clark (PIL Fork Author) aclark@python-pillow.org HPND c:\\programdata\\anaconda3\\envs\\adda\\lib\\site-packages convpic2ico, pystray, win10ctypestoast ((cffi, >=1.15.1), (defusedxml, >=0.7.1), (ipython, >=8.12.0), (numpy, >=1.24.2), (olefile, >=0.46), (packaging, >=23.0), (PyQt5, >=5.15.9), (PyQt6, >=6.4.2), (PySide2, >=5.15.2.1), (PySide6, >=6.5.0)) 1\r\n\r\n88 pystray ((Pillow, None), (six, None)) C:\\ProgramData\\anaconda3\\envs\\adda\\lib\\site-packages\\pystray 0.19.4 Provides systray integration https://github.com/moses-palmer/pystray Moses Palm\u00e9r moses.palmer@gmail.com LGPLv3 c:\\programdata\\anaconda3\\envs\\adda\\lib\\site-packages Pillow, six win10ctypestoast ((AppKit, >=0.2.8), (Foundation, >=0.1.0a0.dev1), (Pillow, >=9.5.0), (six, >=1.16.0), (Xlib, >=0.21)) 1\r\n\r\n66 numpy () C:\\ProgramData\\anaconda3\\envs\\adda\\lib\\site-packages\\numpy 1.24.2 Fundamental package for array computing in Python https://www.numpy.org Travis E. Oliphant et al. BSD-3-Clause c:\\programdata\\anaconda3\\envs\\adda\\lib\\site-packages a-cv-imwrite-imread-plus, a-pandas-ex-fastloc, a-pandas-ex-numexpr, a-pandas-ex-plode-tool, check-if-nan, group-and-iter-everything, locate-pixelcolor, npfastsortcpp, numexpr, opencv-python, pandas, pdmemedit, PrettyColorPrinter ((charset_normalizer, >=3.1.0), (Cython, >=0.29.33), (genapi, >=0.0.8), (hypothesis, >=6.70.2), (mtrand, >=0.1), (mypy, >=1.1.1), (nose, >=1.3.7), (numarray, >=1.5.1), (Numeric, >=24.2), (pickle5, >=0.0.12), (psutil, >=5.9.4), (PyInstaller, >=5.9.0), (pytest, >=7.2.2), (pytz, >=2023.2), (scipy, >=1.10.1), (setuptools, >=65.6.3), (threadpoolctl, >=3.1.0), (typing_extensions, >=4.5.0)) 2\r\n\r\n98 six () <NA> 1.16.0 Python 2 and 3 compatibility utilities https://github.com/benjaminp/six Benjamin Peterson benjamin@python.org MIT c:\\programdata\\anaconda3\\envs\\adda\\lib\\site-packages asttokens, bleach, pystray, python-dateutil <NA> 2\r\n\r\n14 charset-normalizer () C:\\ProgramData\\anaconda3\\envs\\adda\\lib\\site-packages\\charset_normalizer 3.1.0 The Real First Universal Charset Detector. Open, modern and actively maintained alternative to Chardet. https://github.com/Ousret/charset_normalizer Ahmed TAHRI ahmed.tahri@cloudnursery.dev MIT c:\\programdata\\anaconda3\\envs\\adda\\lib\\site-packages requests () 3\r\n\r\n21 Cython () C:\\ProgramData\\anaconda3\\envs\\adda\\lib\\site-packages\\Cython 0.29.33 The Cython compiler for writing C extensions for the Python language. http://cython.org/ Robert Bradshaw, Stefan Behnel, Dag Seljebotn, Greg Ewing, et al. cython-devel@python.org Apache c:\\programdata\\anaconda3\\envs\\adda\\lib\\site-packages npfastsortcpp ((cElementTree, >=1.0.2-20050302), (coverage, >=7.2.2), (Cython, >=0.29.33), (elementtree, >=1.2.6-20050316), (ipython, >=8.12.0), (lxml, >=4.9.2), (Parser, >=0.1), (Pygments, >=2.14.0), (pythran, >=0.12.1), (runtests, >=0.0.28), (setuptools, >=65.6.3)) 3\r\n\r\n83 psutil () C:\\ProgramData\\anaconda3\\envs\\adda\\lib\\site-packages\\psutil 5.9.4 Cross-platform lib for process and system monitoring in Python. https://github.com/giampaolo/psutil Giampaolo Rodola g.rodola@gmail.com BSD-3-Clause c:\\programdata\\anaconda3\\envs\\adda\\lib\\site-packages pdmemedit, subprocess-print-and-capture ((concurrencytest, >=0.1.2), (mock, >=5.0.1), (pip, >=23.0.1), (wheel, >=0.38.4), (wmi, >=1.5.1)) 3\r\n\r\n90 pytz () C:\\ProgramData\\anaconda3\\envs\\adda\\lib\\site-packages\\pytz 2023.2 World timezone definitions, modern and historical http://pythonhosted.org/pytz Stuart Bishop stuart@stuartbishop.net MIT c:\\programdata\\anaconda3\\envs\\adda\\lib\\site-packages pandas ((sets, >=0.3.2), (setuptools, >=65.6.3)) 3\r\n\r\n96 setuptools () C:\\ProgramData\\anaconda3\\envs\\adda\\lib\\site-packages\\setuptools 65.6.3 Easily download, build, install, upgrade, and uninstall Python packages https://github.com/pypa/setuptools Python Packaging Authority distutils-sig@python.org c:\\programdata\\anaconda3\\envs\\adda\\lib\\site-packages npfastsortcpp ((Cython, >=0.29.33), (dl, >=0.1.0), (docutils, >=0.19), (Jinja2, >=3.1.2), (numpy, >=1.24.2), (railroad, >=0.5.0), (setuptools, >=65.6.3), (trove_classifiers, >=2023.3.9)) 3\r\n\r\n86 Pygments () C:\\ProgramData\\anaconda3\\envs\\adda\\lib\\site-packages\\pygments 2.14.0 Pygments is a syntax highlighting package written in Python. https://pygments.org/ Georg Brandl georg@python.org BSD-2-Clause c:\\programdata\\anaconda3\\envs\\adda\\lib\\site-packages ipython, readme-renderer, rich ((chardet, >=5.1.0), (colorama, >=0.4.6), (docutils, >=0.19), (importlib_metadata, >=6.1.0), (Pillow, >=9.5.0), (setuptools, >=65.6.3), (Sphinx, >=6.1.3)) 4\r\n\r\n115 wheel () C:\\ProgramData\\anaconda3\\envs\\adda\\lib\\site-packages\\wheel 0.38.4 A built-package format for Python https://github.com/pypa/wheel Daniel Holth dholth@fastmail.fm MIT c:\\programdata\\anaconda3\\envs\\adda\\lib\\site-packages ((setuptools, >=65.6.3),) 4\r\n\r\n16 colorama () C:\\ProgramData\\anaconda3\\envs\\adda\\lib\\site-packages\\colorama 0.4.6 Cross-platform colored terminal text. Jonathan Hartley <tartley@tartley.com> c:\\programdata\\anaconda3\\envs\\adda\\lib\\site-packages click, ipython ((contextlib2, >=21.6.0), (mock, >=5.0.1)) 5\r\n\r\n```\r\n\r\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Parses all imports and the imports of the imports of a py file into a Pandas DataFrame using pipdeptree/pipreqs/pip",
"version": "0.11",
"split_keywords": [
"pip",
"pipreqs",
"piptree",
"parse",
"imports"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "67ba5657cda45f1d3c39b29e2425850a24410f24400afbd9d23d4eecd0b3ec8a",
"md5": "235659dbbf7656d71b6b66bd2845e9f6",
"sha256": "7e0fd86d68503e49b2a9b77c602c5312167ac3385a2048d50719a385a19b2c9d"
},
"downloads": -1,
"filename": "pip2df-0.11-py3-none-any.whl",
"has_sig": false,
"md5_digest": "235659dbbf7656d71b6b66bd2845e9f6",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 18578,
"upload_time": "2023-04-05T18:52:03",
"upload_time_iso_8601": "2023-04-05T18:52:03.078100Z",
"url": "https://files.pythonhosted.org/packages/67/ba/5657cda45f1d3c39b29e2425850a24410f24400afbd9d23d4eecd0b3ec8a/pip2df-0.11-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "a92fb069ab9411805c7258331e26e417694526747f80070e774adadb042d8108",
"md5": "f4e81fe79bccffbc776f73bcccd1a443",
"sha256": "1c3b5df0c61339d433b3c19e9305622864af04ee70c3028ae624af885f874b8c"
},
"downloads": -1,
"filename": "pip2df-0.11.tar.gz",
"has_sig": false,
"md5_digest": "f4e81fe79bccffbc776f73bcccd1a443",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 18895,
"upload_time": "2023-04-05T18:52:05",
"upload_time_iso_8601": "2023-04-05T18:52:05.402601Z",
"url": "https://files.pythonhosted.org/packages/a9/2f/b069ab9411805c7258331e26e417694526747f80070e774adadb042d8108/pip2df-0.11.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-04-05 18:52:05",
"github": true,
"gitlab": false,
"bitbucket": false,
"github_user": "hansalemaos",
"github_project": "pip2df",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "pip2df"
}