Welcome Guest. Please Login or Register  


You are here: Index > AMPPS > General Support > Topic : I can't run python scripts

2


Threaded Mode | Print  

I can't run python scripts
memzxi
Group: Member
Post Group: Newbie
Posts: 8
Status:
It's not about django, I can't even print a line with python. I was able to run django by it's own runserver, but I guess I will change to php for my project instead of python as it's pain in the ass.
IP: --   

I can't run python scripts
tidus
Group: Member
Post Group: Super Member
Posts: 1121
Status:
Hi,

Just checked it again. Its working fine i.e I am able to print Hello World.
I refered http://code.google.com/p/modwsgi/wiki/QuickConfigurationGuide

-----------------------
Follow AMPPS on,
Twitter : https://twitter.com/AMPPS_Stack
Facebook :  http://www.facebook.com/softaculousampps
Google+ : https://plus.google.com/+AmppsStack
IP: --   

I can't run python scripts
memzxi
Group: Member
Post Group: Newbie
Posts: 8
Status:
Hmz, maybe I was doing something wrong. If you have some spare time consider making a video, just recording your screen while you install ampps and doing the things until hello world is printed. It would help a lot for newbies like me. I don't need it now as I decided to go with php with this project, but I might come back to check python
IP: --   

I can't run python scripts
tidus
Group: Member
Post Group: Super Member
Posts: 1121
Status:
Quote From : memzxi January 21, 2013, 6:35 pm
Hmz, maybe I was doing something wrong. If you have some spare time consider making a video, just recording your screen while you install ampps and doing the things until hello world is printed. It would help a lot for newbies like me. I don't need it now as I decided to go with php with this project, but I might come back to check python


Yes. Sure.

-----------------------
Follow AMPPS on,
Twitter : https://twitter.com/AMPPS_Stack
Facebook :  http://www.facebook.com/softaculousampps
Google+ : https://plus.google.com/+AmppsStack
IP: --   

I can't run python scripts
chrisjensen23
Group: Member
Post Group: Newbie
Posts: 1
Status:
OK, so I got it working on my mac and thought I would share what I did to get it to work.  I followed most of what was in this thread, but with some modifications:

1- Install Ampps

2 - make a folder in your Ampps installation folder, in my case it was here:
    /Applications/AMPPS/www/wsgi-scripts

3 - In the httpd.conf file found here:
    /Applications/AMPPS/conf

configure Apache to allow WSGI scripts, I added the following lines to the virtualhost portion of the httpd.conf

Code
<Directory "/Applications/AMPPS/www/wsgi-scripts">
    Order allow,deny
    Allow from all
    </Directory>

    WSGIScriptAlias /myapp "/Applications/AMPPS/www/wsgi-scripts/myapp.wsgi"


So the whole virtualhost tag looked like this:
Code
<VirtualHost 127.0.0.1:80>
<Directory "/Applications/AMPPS/www">
    Options FollowSymLinks Indexes
    AllowOverride All
    Order deny,allow
    allow from All
    </Directory>
    ServerName localhost
    ServerAlias localhost 127.0.0.1
    ScriptAlias /cgi-bin/ "/Applications/AMPPS/www/cgi-bin/"
    DocumentRoot "/Applications/AMPPS/www"
    ErrorLog "/Applications/AMPPS/apache/logs/error_log"
    CustomLog "/Applications/AMPPS/apache/logs/access.log" combined
   
    <Directory "/Applications/AMPPS/www/wsgi-scripts">
    Order allow,deny
    Allow from all
    </Directory>

    WSGIScriptAlias /myapp "/Applications/AMPPS/www/wsgi-scripts/myapp.wsgi"
   
</VirtualHost>


4 - Edit the python.conf file, located here:
    /Applications/AMPPS/conf

to look like this:
Code
LoadModule wsgi_module modules/mod_wsgi.so
<IfModule wsgi_module>
DirectoryIndex index.wsgi default.wsgi index.py default.py
</IfModule>
WSGIPythonPath "/Applications/AMPPS/python/Lib;/Applications/AMPPS/python/Lib/site-packages;/Applications/AMPPS/python/DLLs"
WSGIPythonHome "/Applications/AMPPS/python"


5-Make a test WSGI application and save it as myapp.wsgi so it should reside in the following folder:
    /Applications/AMPPS/www/wsgi-scripts/

Paste the following code into the myapp.wsgi file that you created:
Code
def application(environ, start_response):
    status = '200 OK'
    output = 'Hello World!'

    response_headers = [('Content-type', 'text/plain'),
                        ('Content-Length', str(len(output)))]
    start_response(status, response_headers)

    return [output]


6 - Restart Apache in Ampps (if it is already open) or Start it for the first time.

7 - load your python test app at http://localhost/myapp

That should do it! 

Quote From : memzxi December 26, 2012, 8:04 pm
Hi. Another newbie here. I thank you for your work creating the product and giving it for free, but after that much work, is it that hard to make Python run by default ?

If I want to run php, I put test.php file in www directory and it works fine. I put test.py and it shows unprocessed source code, the same as it would if I opened it in a browser without AIMPS installed.

Can you just say which file to put where in order for it to work ?

I read quick configuration guide that you posted a link to, but it doesn't seem to help properly.

What I did is put the code below in C:\Program Files\Ampps\apache\conf\httpd.conf in line 634 after << # Python
Include "C:/Program Files/Ampps/python/python.conf" >>

Quote
<VirtualHost *:80>

    ServerName localhost
    ServerAlias 127.0.0.1
    ServerAdmin webmaster@example.com

    DocumentRoot /usr/local/www/documents

    <Directory /usr/local/www/documents>
    Order allow,deny
    Allow from all
    </Directory>

    WSGIScriptAlias /myapp /usr/local/www/wsgi-scripts/myapp.wsgi

    <Directory /usr/local/www/wsgi-scripts>
    Order allow,deny
    Allow from all
    </Directory>

</VirtualHost>


After that, I created the file

C:\Program Files\Ampps\www\wsgi-scripts\myapp.wsgi and put the code below in it. the code is from that "quick" configuration guide

Quote

def application(environ, start_response):
    status = '200 OK'
    output = 'Hello World!'

    response_headers = [('Content-type', 'text/plain'),
                        ('Content-Length', str(len(output)))]
    start_response(status, response_headers)

    return [output]


Then I restarted apache, tried to access
http://localhost/documents/test.py
http://localhost/test.py
http://localhost/wsgi-scripts/test.py

none worked, help ? ( AMPPS installation is fresh, nothing modified )
IP: --   

I can't run python scripts
chiffenok
Group: Member
Post Group: Newbie
Posts: 1
Status:
Hi, everybody. Finally I configured Ampps like it's written in the post 19 but what should I do to run simple script in Browser like this test.py:
Code

#!/usr/local/ampps/python/bin/python
# -*- coding: UTF-8 -*-

# enable debugging
import cgitb
cgitb.enable()

print "Content-Type: text/plain;charset=utf-8"
print

print "Hello World!"

On which folder should I put this file ? wsgi-scripts? Which address should I print in browser ?
Linux, Ampps 2.4
IP: --   

I can't run python scripts
tidus
Group: Member
Post Group: Super Member
Posts: 1121
Status:
Hi,

The folder will be /usr/local/ampps/www/cgi-bin and keep the file extension .cgi


-----------------------
Follow AMPPS on,
Twitter : https://twitter.com/AMPPS_Stack
Facebook :  http://www.facebook.com/softaculousampps
Google+ : https://plus.google.com/+AmppsStack
IP: --   

I can't run python scripts
shovan
Group: Member
Post Group: Newbie
Posts: 7
Status:
I followed instruction in post 19 & 20. I followed your instruction but I get following error

Code

Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator at admin@localhost to inform them of the time this error occurred, and the actions you performed just before this error.

More information about this error may be available in the server error log.


Quote From : tidus July 23, 2014, 7:27 am
Hi,

The folder will be /usr/local/ampps/www/cgi-bin and keep the file extension .cgi
IP: --   

I can't run python scripts
Akirami
Group: Member
Post Group: Newbie
Posts: 1
Status:
Quote From : chrisjensen23 March 26, 2014, 4:07 pm
OK, so I got it working on my mac and thought I would share what I did to get it to work.  I followed most of what was in this thread, but with some modifications:

1- Install Ampps

2 - make a folder in your Ampps installation folder, in my case it was here:
    /Applications/AMPPS/www/wsgi-scripts

3 - In the httpd.conf file found here:
    /Applications/AMPPS/conf

configure Apache to allow WSGI scripts, I added the following lines to the virtualhost portion of the httpd.conf

Code
<Directory "/Applications/AMPPS/www/wsgi-scripts">
    Order allow,deny
    Allow from all
    </Directory>

    WSGIScriptAlias /myapp "/Applications/AMPPS/www/wsgi-scripts/myapp.wsgi"


So the whole virtualhost tag looked like this:
Code
<VirtualHost 127.0.0.1:80>
<Directory "/Applications/AMPPS/www">
    Options FollowSymLinks Indexes
    AllowOverride All
    Order deny,allow
    allow from All
    </Directory>
    ServerName localhost
    ServerAlias localhost 127.0.0.1
    ScriptAlias /cgi-bin/ "/Applications/AMPPS/www/cgi-bin/"
    DocumentRoot "/Applications/AMPPS/www"
    ErrorLog "/Applications/AMPPS/apache/logs/error_log"
    CustomLog "/Applications/AMPPS/apache/logs/access.log" combined
   
    <Directory "/Applications/AMPPS/www/wsgi-scripts">
    Order allow,deny
    Allow from all
    </Directory>

    WSGIScriptAlias /myapp "/Applications/AMPPS/www/wsgi-scripts/myapp.wsgi"
   
</VirtualHost>


4 - Edit the python.conf file, located here:
    /Applications/AMPPS/conf

to look like this:
Code
LoadModule wsgi_module modules/mod_wsgi.so
<IfModule wsgi_module>
DirectoryIndex index.wsgi default.wsgi index.py default.py
</IfModule>
WSGIPythonPath "/Applications/AMPPS/python/Lib;/Applications/AMPPS/python/Lib/site-packages;/Applications/AMPPS/python/DLLs"
WSGIPythonHome "/Applications/AMPPS/python"


5-Make a test WSGI application and save it as myapp.wsgi so it should reside in the following folder:
    /Applications/AMPPS/www/wsgi-scripts/

Paste the following code into the myapp.wsgi file that you created:
Code
def application(environ, start_response):
    status = '200 OK'
    output = 'Hello World!'

    response_headers = [('Content-type', 'text/plain'),
                        ('Content-Length', str(len(output)))]
    start_response(status, response_headers)

    return [output]


6 - Restart Apache in Ampps (if it is already open) or Start it for the first time.

7 - load your python test app at http://localhost/myapp

That should do it! 


Hi there,

After 2 days, i succeded run mod_wsgi whit AMPPS (OS X Yosemite).

The only thing i make is that change:

Code

<VirtualHost 127.0.0.1:80>


to
Code

*:80


and

Quote
ServerAlias localhost 127.0.0.1

to
Code
ServerAlias localhost *


And the whole Virtualhost (httpd.conf):
Quote

<VirtualHost *:80>
<Directory "/Applications/AMPPS/www">
Options FollowSymLinks Indexes
AllowOverride All
Order deny,allow
allow from All
</Directory>
ServerName localhost
ServerAlias localhost *
ScriptAlias /cgi-bin/ "/Applications/AMPPS/www/cgi-bin/"
DocumentRoot "/Applications/AMPPS/www"
ErrorLog "/Applications/AMPPS/apache/logs/error_log"
CustomLog "/Applications/AMPPS/apache/logs/access.log" combined

<Directory "/Applications/AMPPS/www/wsgi-scripts">
Order allow,deny
Allow from all
</Directory>

WSGIScriptAlias /myapp "/Applications/AMPPS/www/wsgi-scripts/myapp.wsgi"
 
</VirtualHost>


Hope it can help someone else.
IP: --   

I can't run python scripts
Perd01
Group: Member
Post Group: Newbie
Posts: 1
Status:
This thread gave me a lot of info to configure AMMPS. However I couldn't get it to work with WSGI until I discovered after checking the error log that the myapp script had to be changed slightly (add b in front of "Hello World"). Than it worked, at least for me....

def application(environ, start_response):
    status = '200 OK'
    output = b'Hello World!'

    response_headers = [('Content-type', 'text/plain'),
                        ('Content-Length', str(len(output)))]
    start_response(status, response_headers)

    return [output]

IP: --   

I can't run python scripts
KenScape
Group: Member
Post Group: Newbie
Posts: 5
Status:
Perd01: I wonder what that does
IP: --   

« Previous    Next »

Threaded Mode | Print  

2


Jump To :


Users viewing this topic
1 guests, 0 users.


All times are GMT. The time now is March 19, 2024, 7:23 am.

  Powered By AEF 1.0.8 © 2007-2008 Electron Inc.Queries: 11  |  Page Created In:0.025