Jump to content

List Installed Python Packages


Recommended Posts

Hello Helioids!

 

Just found this service and started poking around. I'm glad HelioHost exists!

 

Determining without command line access which python packages are available was a bit tricky. I'm documenting a solution here so it will show up for others in search.

 

The following script is tested as working on server Johnny, under Python 3.6. Upload it to, for example, /home/USERNAME/public_html/cgi-bin/SCRIPTNAME.py. Don't forget to make it executable (chmod 755 SCRIPTNAME.py). Sending a request to that file from your browser, for example by visiting YOURSUBDOMAIN.heliohost.org/cgi-bin/SCRIPTNAME.py, will return installed module details wrapped in html that should be good enough for your browser to parse. Hope someone else finds this helpful!

#!/usr/bin/python3.6

import sys
import pip

version = sys.version
modules = pip.get_installed_distributions()

print("Content-type: text/html\n\n", "Python ", version, "<br><br>")

for mod in sorted(modules, key=lambda mod: mod.key):
    try:
        deets = next(pip.commands.show.search_packages_info([mod.key]))
        print(deets["name"], "<br>")
        print(deets["version"], "<br>")
        print(deets["summary"], "<br>")
        print(deets["author"], "<br>")
        print(deets["author-email"], "<br>")
        print(deets["home-page"], "<br><br>")
    except:
        print("<p>", mod.key, "</p>")
Edited by bfirest1
  • Like 1
Link to comment
Share on other sites

One of Heliohost's Admin's Krydos already has a script to view the list of installed modules. The link to view installed modules for python version 3.6 is https://krydos2.heliohost.org/cgi-bin/modules37.py 

 

Similarly this link https://krydos2.heliohost.org/cgi-bin/modules27.py can be used to view the installed modules for python verision 2.7 

 

qsgt

Edited by Krydos
Johnny has been upgraded to python 3.7
Link to comment
Share on other sites

Hello, sorry you couldn't find these links earlier but these all show what packages are available on each version of Python on Tommy, Johnny and Ricky.

 

Johnny:

Python 3.7

Python 2.7

 

Tommy:

Python 2.7

Python 3.7

 

Ricky:

Python 3.6

Python 2.7

Edited by Krydos
Johnny and Tommy have been upgraded to 3.7
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...