Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

No module named pyvirtualdisplay

Tags:

python

apache

I have this import in python code

import time
import sys
from pyvirtualdisplay import Display
from selenium import webdriver

when I run it from centos consol it runs correctly without any error.

Then I created a php file to run the python script with exec php function, and when I run it from centos consol, it runs correctly too, but when I run it from the browser it gives me this error

from pyvirtualdisplay import Display ImportError: No module named pyvirtualdisplay

I tried to give apache the right of executing the python file, but still the same problem.

Any idea about how to fix it?

like image 986
MedYasser.alkahf Avatar asked Aug 26 '15 09:08

MedYasser.alkahf


1 Answers

To be accessible from web server your modules must be installed either:

  • globally with sudo pip install pyvirtualdisplay;
  • or locally with pip --user install pyvirtualdisplay under apache user;
  • or in a virtual environment with pip install pyvirtualdisplay; the script then must be executed with python from that virtual environment; use #!/path/to/venv/bin/python as shebang for your scripts.
like image 135
phd Avatar answered Nov 10 '22 12:11

phd