I'm running a bash script with php which will in turn run a python script but I get so many errors because it seems like www-data
can't use the python packages I have installed for my own user. So how can I make a specific package available for www-data
is it safe to do that? also is it safe to set www-data
as the owner of a specific subtree of /var/www/html
?
Here is the error I get when I run the following command:
sudo -u www-data ./bash_script_that_calls_runs_the_pythonscript.sh
Traceback (most recent call last):
File "./file.py", line 5, in <module>
from bs4 import BeautifulSoup
ImportError: No module named 'bs4'
But if I run:
./bash_script_that_calls_runs_the_pythonscript.sh
Everything will go fine.
And also:
~/.local/lib/python3.5/site-packages$ ll | grep bs4
drwxrwxr-x 5 me www-data 4096 Dec 2 15:37 bs4/
drwxrwxr-x 2 me www-data 4096 Dec 2 15:38 bs4-0.0.1.dist-info/
Please note that I've set the group recursively:
$ ll /home/me/.local/lib/python3.5/site-packages/bs4/
total 180
drwxrwxr-x 5 me www-data 4096 Dec 2 15:37 ./
drwx------ 51 me me 4096 Jan 16 04:33 ../
drwxrwxr-x 3 me www-data 4096 Dec 2 15:37 builder/
-rw-rw-r-- 1 me www-data 29910 Dec 2 15:38 dammit.py
-rw-rw-r-- 1 me www-data 6773 Dec 2 15:38 diagnose.py
-rw-rw-r-- 1 me www-data 68798 Dec 2 15:38 element.py
-rw-rw-r-- 1 me www-data 20394 Dec 2 15:38 __init__.py
drwxrwxr-x 2 me www-data 4096 Dec 2 15:37 __pycache__/
-rw-rw-r-- 1 me www-data 30800 Dec 2 15:38 testing.py
drwxrwxr-x 3 me www-data 4096 Dec 2 15:37 tests/
The same goes for bs4-0.0.1.dist-info/