Jump to content

[Solved] Getting My Python App To Run


strayer

Recommended Posts

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 johnny

I used python 2.7.10

 

thanks for any help!

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

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

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_template
ImportError: No module named flask

 

I would like to have Flask installed for my account on tommy for python 2.7.5

 

thanks!

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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_template

ImportError: 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 by strayer
Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...