strayer Posted July 16, 2017 Posted July 16, 2017 This is the first time I have run a python app from a web host and I have been unable to get it to work.I set it up using web.py on my own computer. I have run it via localhost:8080 on my computer and everything was functional there, but I can't figure out how to get it to work after it has been uploaded. I saw https://www.helionet.org/index/topic/28800-how-to-set-indexpycgi-as-default-index/?hl=python and tried the steps listed in that post as well to no avail. Ultimately that user needed to have python installed and I wanted to know if that was the solution for me as well. I am on server johnnyI used python 2.7.10 thanks for any help!
strayer Posted July 16, 2017 Author Posted July 16, 2017 maybe app is the wrong word. Script? It calls up an html form, does calculations and passes it on to a different html page. it is located at usr/public_html/bin/app.py I also placed a copy of it into cgi-bin to see if I could get it to run there.
Krydos Posted July 16, 2017 Posted July 16, 2017 Cgi scripts won't execute in public_html/bin unless you use .htaccess to make it executable. Everything is executable by default in cgi-bin. Here is the error you're getting: [/home/strayer/public_html/cgi-bin]# /usr/bin/python app.py Traceback (most recent call last): File "app.py", line 3, in <module> import web ImportError: No module named web You can get this error yourself by running a cron with the command /usr/bin/python /home/strayer/public_html/cgi-bin/app.py and that error will be mailed to your contact address. Just be aware that you can only run 2 cron jobs per day. Since Johnny is pretty new python is pretty much stock. You can request modules by posting on these forums. Also /usr/bin/python is Python 2.6.6 which apparently isn't supported anymore and web can't be installed. I recommend using /usr/bin/python3.6
strayer Posted July 16, 2017 Author Posted July 16, 2017 (edited) I am still in the learning process for python and have only used python 2 (I have 2.7.10 on my computer) It would be best for me if I did not have to figure out how to re-do things in python 3 yet. I think it may be best for me to move from Johnny to another server that has python 2.7 installed. Edited July 16, 2017 by strayer
strayer Posted July 16, 2017 Author Posted July 16, 2017 I tried to follow the instructions in http://wiki.helionet.org/Moving_your_account but upon requesting account deletion it said My account could not be found.
Krydos Posted July 16, 2017 Posted July 16, 2017 I see an account on Tommy now so I guess you got it figured out. On Tommy /bin/python is 2.7.5
strayer Posted July 17, 2017 Author Posted July 17, 2017 I did indeed get it figured out! Thanks for checking in. can I get web.py installed? Is there a place I can see the modules that are already installed on Tommy?
Krydos Posted July 17, 2017 Posted July 17, 2017 You can't use flask or django? Tommy Python 2.7.5: ['backports.ssl-match-hostname==3.4.0.2', 'chardet==2.2.1', 'configobj==4.7.2', 'decorator==3.4.0', 'dnspython==1.12.0', 'iniparse==0.4', 'ipy==0.75', 'javapackages==1.0.0', 'kitchen==1.1.1', 'lxml==3.2.1', 'oauthlib==2.0.1', 'perf==0.1', 'pip==9.0.1', 'policycoreutils-default-encoding==0.1', 'pycurl==7.19.0', 'pygobject==3.14.0', 'pygpgme==0.3', 'pyliblzma==0.5.3', 'pyparsing==1.5.6', 'pyudev==0.15', 'pyxattr==0.5.1', 'pyzor==1.0.0', 'requests-oauthlib==0.7.0', 'requests==2.12.5', 'seobject==0.1', 'sepolicy==1.1', 'setuptools==0.9.8', 'six==1.10.0', 'tweepy==3.5.0', 'urlgrabber==3.10', 'yum-metadata-parser==1.1.4']
strayer Posted July 17, 2017 Author Posted July 17, 2017 I think flask will work for me. I re-wrote the script to use flask.Does that module need to be installed for me? Thank you for all of your help!
strayer Posted July 18, 2017 Author Posted July 18, 2017 I ran a cron job and received: Traceback (most recent call last): File "/home/estrayer/public_html/cgi-bin/app.py", line 3, in <module> from flask import Flask, session, request, render_templateImportError: No module named flask I would like to have Flask installed for my account on tommy for python 2.7.5 thanks!
wolstech Posted July 18, 2017 Posted July 18, 2017 If I remember right, Flask is installed for 3.6. Escalating to see if it can be installed for 2.7.
Krydos Posted July 18, 2017 Posted July 18, 2017 Flask, and Django and other python frameworks like this can only be installed on one version of python per server. Tommy already has flask and django on python 3.6. If you want to use python 2.7.5 you'll need to stick with cgi. The other option is we could do django/flask/web.py or whatever on python 2.7 when we rebuild Ricky. That way we'd be able to offer the frameworks on both major versions of python depending on which server people choose. Ricky is scheduled to be rebuilt sometime in August. Let us know if you'd be interested in flask, django, or web.py on python 2.7 before then.
strayer Posted July 19, 2017 Author Posted July 19, 2017 (edited) I adjusted my script so it will run on python 3.6 I tested on my computer using localhost and it worked. I changed the shebang on app.py and I am still getting the same cron error. Traceback (most recent call last): File "/home/estrayer/public_html/cgi-bin/app.py", line 3, in <module> from flask import Flask, session, request, render_templateImportError: No module named flask I have tried both #! usr/bin/python3 and #! usr/bin/python3.6 what am I doing wrong?Thanks so much for your help, sorry to be a pain. Edit:realized I did not adjust my cron to usr/bin/python3 just made that change and set it to run in a few minutes. Hopefully that will show me where my next error is. Edited July 19, 2017 by strayer
Krydos Posted July 19, 2017 Posted July 19, 2017 Just be aware that you can only run 2 cron jobs per day. Check out https://www.helionet.org/index/topic/27822-how-do-i-use-flask-on-johnny/?p=128919
Recommended Posts