I have some problem.
this php (uploads.php) script execute gif.py python file.
<?php
$file_path = "uploads/";
$auth_token = $_POST['auth_token'];
mysql_connect('localhost',"login",'pass');
mysql_set_charset("UTF-8");
mysql_select_db("DB_name");
$sql = "SELECT user_id FROM users WHERE auth_token='$auth_token'";
$result = mysql_query($sql);
if(mysql_fetch_array($result)['user_id']==0)
{
echo "fail auth_token ".$auth_token;
exit;
}
$file_md5 = md5(time()+$auth_token+rand(0,1000));
$file_path = $file_path . basename( $_FILES['uploaded_file']['name']);
if(move_uploaded_file($_FILES['uploaded_file']['tmp_name'], "uploads/".$file_md5.".mp4")) {
$aaa = exec("/usr/bin/python gif.py b9022c5c317cf2317ad3f537dcc1cfbe");
echo $file_md5." ".$aaa;
} else{
echo "fail ".$_FILES['uploaded_file']['size']." ".$_FILES['uploaded_file']['tmp_name']." ".$file_path ;
}
?>
gif.py file
#!/usr/bin/env python
from moviepy.editor import *
import sys
file_md5 = sys.argv[1]
anna_olaf = (VideoFileClip("uploads/" + file_md5+".mp4")
.subclip(0,1)
.resize(1))
anna_olaf.write_gif('gifs/test.gif', fps=15)
I have in uploads folder b9022c5c317cf2317ad3f537dcc1cfbe.mp4 file. Where i call gif.py or uploads.php file from the Linux console all ok(php uploads.php OR pyhon gif.py), but where I call uploads.php from browser python file don't work, in apache log i find
/usr/lib/python2.7/dist-packages/IPython/utils/path.py:296: UserWarning: IPython parent '/var/www' is not a writable location, using a temp directory.
" using a temp directory."%parent)
Traceback (most recent call last):
File "gif.py", line 2, in <module>
from moviepy.editor import *
File "/usr/local/lib/python2.7/dist-packages/moviepy-0.2.1.8.12-py2.7.egg/moviepy/editor.py", line 45, in <module>
from .video.io.sliders import sliders
File "/usr/local/lib/python2.7/dist-packages/moviepy-0.2.1.8.12-py2.7.egg/moviepy/video/io/sliders.py", line 1, in <module>
import matplotlib.pyplot as plt
File "/usr/lib/pymodules/python2.7/matplotlib/__init__.py", line 774, in <module>
rcParams = rc_params()
File "/usr/lib/pymodules/python2.7/matplotlib/__init__.py", line 692, in rc_params
fname = matplotlib_fname()
File "/usr/lib/pymodules/python2.7/matplotlib/__init__.py", line 604, in matplotlib_fname
fname = os.path.join(get_configdir(), 'matplotlibrc')
File "/usr/lib/pymodules/python2.7/matplotlib/__init__.py", line 253, in wrapper
ret = func(*args, **kwargs)
File "/usr/lib/pymodules/python2.7/matplotlib/__init__.py", line 478, in _get_configdir
raise RuntimeError("Failed to create %s/.matplotlib; consider setting MPLCONFIGDIR to a writable directory for matplotlib configuration data"%h)
RuntimeError: Failed to create /var/www/.matplotlib; consider setting MPLCONFIGDIR to a writable directory for matplotlib configuration data
Please help, in log write error in 2 line ( from moviepy.editor import * ) but why I not have error where call ( python gif.py )?
RuntimeError: Failed to create /var/www/.matplotlib; consider setting MPLCONFIGDIR to a writable directory for matplotlib configuration dataI would say it's probably a permissions problem with the/var/www/folder not allowing the script to create the file as needed.