The error is only happened in web. If I run it in console, it is OK.I am working in ubuntu.
I have setup apache2 using CGI for handle python and tried to displayed the python version in the code and can prove web and console both running on same python version and user.
But as long as import lxml.etree, I got the error below.
Traceback (most recent call last):
File "/usr/lib/cgi-bin/TestPy.py", line 3, in <module>
import lxml.etree as ET
ImportError: No module named lxml.etree
My CGI config is as below: Filename: serve-cgi-bin.conf
<IfDefine ENABLE_USR_LIB_CGI_BIN>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Require all granted
#AddHandler cgi-script .py
#Order allow,deny
#Allow from all
</Directory>
</IfDefine>
My python code is as below:
#!/usr/bin/python
import lxml.etree as ET
import sys
print "Content-Type: text/plain\r\n\r\n"
print "Hello World!"
print "[" + sys.version + "]" + " [" + sys.prefix + "]"
#xml_filename='/var/www/htmprint/Water.xml'
#xsl_filename='/var/www/htmprint/Water.xsl'
#dom = ET.parse(xml_filename)
#xslt = ET.parse(xsl_filename)
#transform = ET.XSLT(xslt)
#newdom = transform(dom)
#print(ET.tostring(newdom, pretty_print=True))
I got the feeling the permission isn't quite right for the lxml.etree file but I cannot figure out this.
Thanks in advance if anyone can help.
Bin
Install the package to the global site-packages, not your .local which is your personal space.