Jump to content

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


jcook

Recommended Posts

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
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

  • 3 weeks later...

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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
Link to comment
Share on other sites

  • 1 month later...

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!

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

  • 5 months later...

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...