title: PHP program can't execute piCamera function in Python script
body: <p>I am making a php program that executes a Python script in which a camera is recording. The camera is plugged to a Raspberry Pi.
  Here is the Python script (I am using Python3) :</p>
  <pre><code>#import time
  import datetime
  import subprocess
  import os
  import sys
  from picamera import PiCamera
  
  
  T = 0
  N = 0
  A = 0
  
  print(&quot;0&quot;)
  
  TITLE = &quot;maelan&quot; #sys.argv[1]
  S = 1 #sys.argv[2]
  USER_NAME = &quot;MaElAn&quot; #sys.argv[3]
  TIME = int(S)
  #SRC = './src'
  #DST = './mp4'
  VIDEO_IN = TITLE + &quot;.mp4&quot;
  PATH_VID = &quot;/var/www/html/superv/public/user_&quot; + USER_NAME + &quot;/&quot;
  NEW_PATH_VID = PATH_VID + &quot;exp_&quot; + TITLE + &quot;/&quot;
  #IMG = TITLE + &quot;_&quot; + str(T)
  
  print(&quot;1&quot;)
  
  if not os.path.exists(NEW_PATH_VID + &quot;img&quot;):
      os.makedirs(NEW_PATH_VID + &quot;img&quot;)
  print(&quot;1.5&quot;)
  if not os.path.exists(PATH_VID + &quot;exp_&quot; + TITLE):
      os.system(&quot;mkdir &quot; + PATH_VID + &quot;exp_&quot; + TITLE)
  print(&quot;1.75&quot;)
  
  VIDEO_OUT = NEW_PATH_VID + &quot;compressed_&quot; + TITLE + &quot;.mp4&quot;
  
  #print (sys.argv)
  
  print(&quot;2&quot;)
  #os.system(&quot;/usr/bin/octave /home/pi/SOE/Frames/analyser.m&quot;)
  
  
  CAMERA = PiCamera()
  print(&quot;3&quot;)
  CAMERA.resolution = (1280, 720)
  CAMERA.framerate = 25
  CAMERA.image_effect = &quot;negative&quot;
  #CAMERA.start_preview()
  CAMERA.start_recording(TITLE + &quot;.h264&quot;)
  
  #Horodatage dynamique
  while T &lt; TIME:
      #CAMERA.capture(&quot;/home/pi/SOE/img/&quot; + IMG + &quot;.jpg&quot;)
      NOW = datetime.datetime.now()
      CAMERA.annotate_text = NOW.strftime(&quot;%Y-%m-%d %H:%M:%S &quot; + TITLE)
      CAMERA.wait_recording(1)
      T = T + 1
  
  CAMERA.stop_recording()
  #CAMERA.stop_preview()
  print(&quot;3&quot;)
  </code></pre>
  <p>I call this scrip via a php shell_exec function. Here is the php code :</p>
  <pre><code>$out=shell_exec('progVideo.py');
  echo $out;
  </code></pre>
  <p>The python script executes well, until this line :</p>
  <pre><code>CAMERA = PiCamera()
  </code></pre>
  <p>I feel like php doesn't have permissions to access the camera plugged to the Raspberry.I did <code>chmod 777 /var/www</code> and <code>chmod 777 /dev/vchiq</code> but nothing works. The camera doesn't record anything. Pls help :)</p>