python - lxml installed, but not working on Windows -


i need validate xml file against xsd. accomplish use lxml library. problem though have from lxml import etree , have installed lxml c:\python33\lib\site-packages\lxml\, i'm getting error

traceback (most recent call last):   file "c:\users\asmithe\documents\dev1\testparse.py", line 3, in <module>     lxml import etree et_l importerror: no module named lxml 

why , how fix it? tried adding c:\python33\lib\site-packages\lxml\ path variable , didn't help. had installed lxml using pip.

update: when run script through interactive terminal (i.e. typing python in cmd) can import lxml

here simple script

from lxml import etree  def main():     print('hi')   if __name__ == "__main__":     main() 

in cmd do

c:\users\dev1\documents\test>python python 3.3.5 (v3.3.5:62cf4e77f785, mar  9 2014, 10:35:05) [msc v.1600 64 bit (am d64)] on win32 type "help", "copyright", "credits" or "license" more information. >>> lxml import etree >>> >>> def main(): ...     print('hi') ... >>> >>> if __name__ == "__main__": ...     main() ... hi >>> exit() 

however if try run it

> importlxml.py 

then

c:\users\dev1\documents\test>importlxml.py traceback (most recent call last):   file "c:\users\dev1\documents\xml test\testimport.py", line 1, in <module>      lxml import etree importerror: no module named lxml 

here of pythonic entries in path environment variable

c:\python33\; c:\python33\scripts; c:\python33\lib\site-packages\lxml\ %arcgisinsalldir%\arcpy; 

configure python launcher windows use 3.3.5 default:

py -3 

alternately -- assuming chose install python launcher when last installing python -- begin script shebang python launcher recognize requesting python 3:

#! python3 

if decided not install python launcher windows when installing python 3.3, see the install documentation manual steps:

associate correct file group .py scripts:

assoc .py=python.file 

redirect python files new executable:

ftype python.file=c:\path\to\pythonw.exe "%1" %* 

this can used configure type python.file python interpreter of choice, ie. 3.3.5. (as matter of practices, python.file should pointed @ py.exe or python.exe; pythonw.exe example above direct quote docs, bad practice nonetheless).


alternately, if have py.exe on disk (installed python 3.3) isn't being used, can modify instructions bit:

associate correct file group .py scripts:

assoc .py=python.file 

redirect python files new executable:

ftype python.file=c:\path\to\py.exe "%1" %* 

...again, adjusting path appropriate installed python 3.3.x.


Comments

Popular posts from this blog

python - Healpy: From Data to Healpix map -

c - Bitwise operation with (signed) enum value -

xslt - Unnest parent nodes by child node -