简体   繁体   中英

[Linux, Ubuntu]: Executing a Python script with different users results in different behaviours

I'm trying to execute a script in Ubuntu with Python with my user "ubuntu". It's a virtual machine of Amazon, so I'm trying to execute that code

$execQuery = "python script.py";
exec($execQuery, $output, $return);

by executing that command with ubuntu the results is OK , but executing it from PHP (which user is www-data ), I get:

ImportError: No module named skimage.io

So I think there's an error about permission, but since I've never used Python, I don't know where I have to put the right permissions.

Does anyone have a clue?

Thank you very much.


I've tried to use pip install ___ --user www-data but didn't work either.

Well, this is weird, while it was working from the main user, it wasn't working from www-data .

The problem, obviously was in the sckit-image Python module and I thought it was a permission problem . In fact, the www-data user wasn't locating the right library even if I set the $PYTHONPATH and y tried to import it as well from the script as:

import sys
sys.path.insert(0, "path/to/python");

but nothing happened.

When installing the scikit-image. There was an error on the scipy which was giving me at the same time an error with gfortran .

sudo apt-get install gfortran and reinstalling scipy and scikit-image resolved the problem.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM