{"id":543,"date":"2017-09-30T13:35:51","date_gmt":"2017-09-30T18:35:51","guid":{"rendered":"http:\/\/bluegalaxy.info\/codewalk\/?p=543"},"modified":"2021-01-17T21:32:21","modified_gmt":"2021-01-18T02:32:21","slug":"python-how-to-get-a-list-of-all-available-python-modules","status":"publish","type":"post","link":"https:\/\/bluegalaxy.info\/codewalk\/2017\/09\/30\/python-how-to-get-a-list-of-all-available-python-modules\/","title":{"rendered":"Python on the web: How to get a list of all available Python modules"},"content":{"rendered":"\n<p>If you want to get a complete list of Python modules available on your web host, you can do so with the following code:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">#!\/usr\/bin\/python\n\nimport os\n\nprint \"Content-type: text\/html\\n\\n\";\nprint \"&lt;html>&lt;head>&lt;\/head>\"\nprint \"&lt;body bgcolor='#ffffff'>\"\n\nprint \"\\n&lt;BR>&lt;b>Available Modules:&lt;\/b>&lt;BR>\"\n\n# List all installed packages\nprint '&lt;ul>'\ndist_list = []\nfor dist in __import__('pkg_resources').working_set:\n    dist_list.append(dist.project_name.replace('Python', '').strip())\n    \ndist_list = list(filter(None, dist_list))\nfor dist in dist_list:\n    print \"\\n&lt;li>\", dist, '&lt;\/li>'   \nprint '&lt;\/ul>'\n\nprint \"&lt;\/body>&lt;\/html>\"<\/pre>\n\n\n\n<p>I saved the above code as a CGI script called &#8220;available_modules.py&#8221; and uploaded it to my website cgi-bin. Here is what the code produces, shown below in an iframe:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"html\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\n<!-- iframe plugin v.5.2 wordpress.org\/plugins\/iframe\/ -->\n<iframe loading=\"lazy\" src=\"http:\/\/bluegalaxy.info\/cgi-bin\/available_modules.py\" width=\"100%\" height=\"600\" scrolling=\"yes\" class=\"iframe-class\" frameborder=\"0\"><\/iframe>\n<\/pre>\n\n\n\n<!-- iframe plugin v.5.2 wordpress.org\/plugins\/iframe\/ -->\n<iframe loading=\"lazy\" src=\"https:\/\/bluegalaxy.info\/cgi-bin\/available_modules.py\" width=\"100%\" height=\"750\" frameborder=\"1\" style=\"border-radius: 20px;\" scrolling=\"yes\" class=\"iframe-class\"><\/iframe>\n\n\n\n\n<p><\/p>\n\n\n\n<p>For more information about pkg_resources, see:<br>\n<a href=\"https:\/\/setuptools.readthedocs.io\/en\/latest\/pkg_resources.html#package-discovery-and-resource-access-using-pkg-resources\">https:\/\/setuptools.readthedocs.io\/en\/latest\/pkg_resources.html#package-discovery-and-resource-access-using-pkg-resources<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>If you want to get a complete list of Python modules available on your web host, you can do so with the following code: I saved the above code as a CGI script called &#8220;available_modules.py&#8221; and uploaded it to my website cgi-bin. Here is what the code produces, shown below in an iframe: For more &hellip; <a href=\"https:\/\/bluegalaxy.info\/codewalk\/2017\/09\/30\/python-how-to-get-a-list-of-all-available-python-modules\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Python on the web: How to get a list of all available Python modules<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[19,22],"tags":[16,42,4],"class_list":["post-543","post","type-post","status-publish","format-standard","hentry","category-python-cgi","category-python-language","tag-cgi","tag-iframe","tag-python"],"_links":{"self":[{"href":"https:\/\/bluegalaxy.info\/codewalk\/wp-json\/wp\/v2\/posts\/543","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/bluegalaxy.info\/codewalk\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/bluegalaxy.info\/codewalk\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/bluegalaxy.info\/codewalk\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/bluegalaxy.info\/codewalk\/wp-json\/wp\/v2\/comments?post=543"}],"version-history":[{"count":18,"href":"https:\/\/bluegalaxy.info\/codewalk\/wp-json\/wp\/v2\/posts\/543\/revisions"}],"predecessor-version":[{"id":3372,"href":"https:\/\/bluegalaxy.info\/codewalk\/wp-json\/wp\/v2\/posts\/543\/revisions\/3372"}],"wp:attachment":[{"href":"https:\/\/bluegalaxy.info\/codewalk\/wp-json\/wp\/v2\/media?parent=543"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/bluegalaxy.info\/codewalk\/wp-json\/wp\/v2\/categories?post=543"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/bluegalaxy.info\/codewalk\/wp-json\/wp\/v2\/tags?post=543"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}