Jump to content

Where should I post instructions for installing python packages (with CGI)?


Recommended Posts

Posted

So I just started using the Johnny server, wanting to integrate some of my python scripts into the web. I decided to use cgi scripts since I'm a beginner.

 

I looked around on the forms and Google trying to find out how to install various python packages. I've seen some posts on the forms requesting installs but I didn't want to both them with it. Cron jobs kind of worked the couple times I tried, but with only 2 allowed per day that was really limiting.

 

I found a great way for users to install python packages on their server with no hoops to jump through. I'm wondering where I should post this information to help others - a forum category, wiki, somewhere else?

 

Script is at jcook.heliohost.org/cgi-bin/install-packages.py for anyone wanting to take a look. It has to have permissions set to 755 and you install by just visiting the page. Delete when done.

  • Like 1
Posted

The wiki https://wiki.helionet.org/ is probably the best place, or you can just post it in this forum. If you choose to go with the wiki you'll need to create a separate wiki account, and post your username here so we can promote you. That will allow you to make edits.

Posted

Cool, thanks! I'll get around to it sometime in the next day or two. I was pleasantly surprised when it worked (after a few days of trying other methods and failing).

 

It's pretty much just importing pip then using pip.main(['install','--user','package-name']). If anyone has any issues with the method feel free to reply to this thread.

  • 3 weeks later...
Posted

So it looks like I won't be able to actually add anything to the wiki since I do not meet the requirements, bummer. Maybe someday I'll qualify but who knows. Hopefully if someone needs to know they'll look it up in the forums!!

 

I also just noticed that using my method created a .local directory in the /home/username root and then inside it a python3.6 folder (as well as a python2.6 and python2.7 depending on which python version I used to install). I think creating that /home/user/.local/python3.6 directory and adding packages there instead may theoretically work, provided you've met all of the dependencies.

Posted

You can edit the wiki if you want. The twenty posts rule is mainly just there to make sure people are willing to contribute to the community. If you let us know your wiki username you can get promoted to have access to edit.

 

Regarding installing your own python modules, there have been a few different methods posted on the forums over the years that work, but most people find it easier to just make a post asking an admin to install it for them. We don't mind installing the modules. It takes less than a minute and it's a lot less complicated for people.

Posted (edited)
print("Content-Type: text/html\n\n")
import cgi
import cgitb
import pip
cgitb.enable()


print("""<!DOCTYPE html>
<html lang="en" >
<head> 
  <title>Pip for patents</title>
</head>
<body>""")


form = cgi.FieldStorage()
module = form.getvalue("module")
version = form.getvalue("version")


if module and version:
    module_version = "{module}=={version}"
    pip.main(['install', '--user', module_version])
elif module:
    pip.main(['install', '--user', module])
else:
    print("Installed module for user patents on heliohost.")
    print("  <ul>")
    for module in pip.get_installed_distributions():
        print("    <li>{m}: {v}</li>".format(
            m=module.key, v=module.version
        ))
        
    print("  </ul>")
print("</body></html>")

Thanks to krydos for helping me write this script but I rarely use it. I just post request and krydos is fast enough to install module before I actually use it 

Edited by patents
  • 1 month later...
Posted

Whoaw, sorry I didn't see these responses until now! I thought I would get email notifications.  :wacko:

Posted

You can edit the wiki if you want. The twenty posts rule is mainly just there to make sure people are willing to contribute to the community. If you let us know your wiki username you can get promoted to have access to edit.

 

Regarding installing your own python modules, there have been a few different methods posted on the forums over the years that work, but most people find it easier to just make a post asking an admin to install it for them. We don't mind installing the modules. It takes less than a minute and it's a lot less complicated for people.

My wiki username is jcook just like my forum and HelioHost userbame. :) I'd love to contribute in any way I can!

Posted

Thanks wolstech!!! I also fixed my notification settings so I got an email right away when you replied. :)

 

I'll try to contribute as I have time and come across helpful knowledge.

  • 5 months later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...