0

I am trying to write a python script that will record some sound when called from a browser. I am using XAMPP on my macbook pro as a test server. Pyaudio is the package I am using to collect the sound samples. I ran the installer for it and can import and utilize it just fine but when the script is executed by apache, the import fails. I can import standard packages fine however.

When apache runs this script:

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

# enable debugging
import sys
import cgitb
cgitb.enable()

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

I get this error in the browser: Please build and install the PortAudio Python bindings first.

Running this in the shell however is not a problem.

I have tried changing to the hashbang heading to the exact location of my shell interpreter but that made no difference.

  • Apache runs under a different user with a different (usually quite restricted) environnement and different permissions. – bruno desthuilliers Jun 02 '15 at 16:13
  • Do you know of any online resources that explain the limitations? I assume they can be changed? – user3003437 Jun 02 '15 at 18:37
  • How apache is installed, how your Python packages are installed etc really depends on the system (it's not even consistant from one linux distro to another) so you'll have to check on a MacOS forum I think (for the MacOS specific part), and of course at Apache's doc. You may also want to read about Python's `virtualenv` too - not sure it works on MacOS but if yes it's something you want to use for your projects. – bruno desthuilliers Jun 02 '15 at 19:30

0 Answers0