Jump to content


Photo

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


  • Please log in to reply
13 replies to this topic

#1 jcook

jcook

    Rank I Member

  • Members
  • Pip
  • 12 posts
  • Gender:Female
  • Location:Twin Cities Metro, MN

Posted 17 February 2018 - 03:57 AM

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.

#2 Krydos

Krydos

    Rank X Member

  • Root Admin
  • 17,575 posts
  • Gender:Male

Posted 17 February 2018 - 03:59 AM

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.

#3 jcook

jcook

    Rank I Member

  • Members
  • Pip
  • 12 posts
  • Gender:Female
  • Location:Twin Cities Metro, MN

Posted 17 February 2018 - 04:05 AM

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.

#4 patents

patents

    Rank II Member

  • Members
  • PipPip
  • 85 posts
  • Gender:Male
  • Location:India
  • Interests:Python, Django

Posted 23 February 2018 - 05:52 AM

This is powerful feature. Please use it with care.



#5 jcook

jcook

    Rank I Member

  • Members
  • Pip
  • 12 posts
  • Gender:Female
  • Location:Twin Cities Metro, MN

Posted 10 March 2018 - 11:08 PM

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.

#6 Krydos

Krydos

    Rank X Member

  • Root Admin
  • 17,575 posts
  • Gender:Male

Posted 11 March 2018 - 01:18 AM

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.

#7 michaeltim

michaeltim

    Rank I Member

  • Banned
  • Pip
  • 29 posts
  • Gender:Male

Posted 13 March 2018 - 07:27 AM

thanks for sharing 



#8 patents

patents

    Rank II Member

  • Members
  • PipPip
  • 85 posts
  • Gender:Male
  • Location:India
  • Interests:Python, Django

Posted 13 March 2018 - 10:41 AM

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, 13 March 2018 - 10:44 AM.


#9 jcook

jcook

    Rank I Member

  • Members
  • Pip
  • 12 posts
  • Gender:Female
  • Location:Twin Cities Metro, MN

Posted 16 April 2018 - 05:30 PM

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



#10 jcook

jcook

    Rank I Member

  • Members
  • Pip
  • 12 posts
  • Gender:Female
  • Location:Twin Cities Metro, MN

Posted 16 April 2018 - 05:32 PM

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!



#11 wolstech

wolstech

    Rank X Member

  • Root Admin
  • 9,899 posts
  • Gender:Male
  • Location:Pennsylvania

Posted 16 April 2018 - 05:45 PM

Added. You should now be able to edit the wiki.


Please do not PM me for support. Posting on our forums lets all of us learn.

Do you play Minecraft? | Server Monitors | And the Dumbass of the Decade award goes to...


#12 jcook

jcook

    Rank I Member

  • Members
  • Pip
  • 12 posts
  • Gender:Female
  • Location:Twin Cities Metro, MN

Posted 16 April 2018 - 05:53 PM

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.

#13 agatuz12

agatuz12

    Newbie

  • Members
  • 3 posts

Posted 05 October 2018 - 04:05 PM

Sorry if I reopen an old topic but I don't understand how to install python modules.

Can someone help me, please?



#14 Krydos

Krydos

    Rank X Member

  • Root Admin
  • 17,575 posts
  • Gender:Male

Posted 06 October 2018 - 06:22 PM

Post the version of python you're using, and the module you need and an admin can install it for you.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users