No module named expat; use SimpleXMLTreeBuilder instead

1,724 views
Skip to first unread message

Dinesh Kumar

unread,
Jan 6, 2017, 3:51:22 AM1/6/17
to robotframework-users
Hello,
I am new user to RF.
I installed my  Robot Framework 3.0 (Python 2.6.6 ) on my linux host (2.6.32-358.el6.x86_64  x86_64 GNU/Linux).
I installed RF as user ROOT using "pip install robotframework".

Problem: My test cases are failing to create the Log /Result files when run as normal user (in my case "oracle") with below error message.
              But same test cases are running properly when run as user ROOT (i.e. super user who installed RF). But I need to have 'dba' (oracle) privileges to run my test cases.

Error Message:
Output:  /home/scripts/robot/output.xml
[ ERROR ] Reading XML source '/home/scripts/robot/output.xml' failed: ImportError: No module named expat; use SimpleXMLTreeBuilder instead


I verified the known issues related to PYTHONPATH / Libs etc, they look normal as seen below.
[oracle@host ~]$ python -c "import xml.parsers.expat"
[oracle@host ~]$

[oracle@host ~]$ python -c "import sys ; print sys.path"
['', '/usr/lib64/python26.zip', '/usr/lib64/python2.6', '/usr/lib64/python2.6/plat-linux2', '/usr/lib64/python2.6/lib-tk', '/usr/lib64/python2.6/lib-old', '/usr/lib64/python2.6/lib-dynload', '/usr/lib64/python2.6/site-packages', '/usr/lib64/python2.6/site-packages/PIL', '/usr/lib64/python2.6/site-packages/gst-0.10', '/usr/lib64/python2.6/site-packages/gtk-2.0', '/usr/lib64/python2.6/site-packages/webkit-1.0', '/usr/lib/python2.6/site-packages', '/usr/lib/python2.6/site-packages/setuptools-0.6c11-py2.6.egg-info']

 Note: RF is installed under PATH  /usr/lib/python2.6/site-packages.

I even tried to provide SUDOERS permission to both robot and python, for user 'oracle' but no result.
Please advise.
Regards
Dinesh Kumar.

Hélio Guilherme

unread,
Jan 6, 2017, 5:17:29 AM1/6/17
to kumar....@gmail.com, robotframework-users
I can't pinpoint what your problem is but here are my thoughts:
- The problem is with the `rebot` tool, since you have the output.xml file ready.
  Try `rebot /home/scripts/robot/output.xml` and confirm the same error. If using sudo or root account the error does not exist?
- Maybe you have two pythons installations, one 64bit and another 32bit (and user environment setup is different)
  (Consider running `python -c "import sys ; print sys.path"` as root, and compare with user oracle. Maybe the path order is different.)
- Is it possible to consider installing Python 2.7? Maybe that would help, and 2.6 will soon not be supported.
 (Consider using virtualenv)

Good luck.

--
You received this message because you are subscribed to the Google Groups "robotframework-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to robotframework-users+unsub...@googlegroups.com.
To post to this group, send email to robotframework-users@googlegroups.com.
Visit this group at https://groups.google.com/group/robotframework-users.
For more options, visit https://groups.google.com/d/optout.

Dinesh Kumar

unread,
Jan 6, 2017, 7:07:05 AM1/6/17
to robotframework-users, kumar....@gmail.com
Thanks for the quick reply and find  below are responses.
I found a work  around ( by setting the setuid/preexec_fn) to switch the user for the test command. So can continue my testing now. 

1) I confirmed rebot is only failing for user 'oracle' and not for user root. (see below)
[oracle@host robot]$ rebot output.xml
[ ERROR ] Reading XML source 'output.xml' failed: ImportError: No module named expat; use SimpleXMLTreeBuilder instead

2)Python installation seem to be ok, as the PATH order is same for both users as below.

[root@host robot]# python -c "import sys ; print sys.path"
['', '/usr/lib64/python26.zip', '/usr/lib64/python2.6', '/usr/lib64/python2.6/plat-linux2', '/usr/lib64/python2.6/lib-tk', '/usr/lib64/python2.6/lib-old', '/usr/lib64/python2.6/lib-dynload', '/usr/lib64/python2.6/site-packages', '/usr/lib64/python2.6/site-packages/PIL', '/usr/lib64/python2.6/site-packages/gst-0.10', '/usr/lib64/python2.6/site-packages/gtk-2.0', '/usr/lib64/python2.6/site-packages/webkit-1.0', '/usr/lib/python2.6/site-packages', '/usr/lib/python2.6/site-packages/setuptools-0.6c11-py2.6.egg-info']


[oracle@host robot]$ python -c "import sys ; print sys.path"
['', '/usr/lib64/python26.zip', '/usr/lib64/python2.6', '/usr/lib64/python2.6/plat-linux2', '/usr/lib64/python2.6/lib-tk', '/usr/lib64/python2.6/lib-old', '/usr/lib64/python2.6/lib-dynload', '/usr/lib64/python2.6/site-packages', '/usr/lib64/python2.6/site-packages/PIL', '/usr/lib64/python2.6/site-packages/gst-0.10', '/usr/lib64/python2.6/site-packages/gtk-2.0', '/usr/lib64/python2.6/site-packages/webkit-1.0', '/usr/lib/python2.6/site-packages', '/usr/lib/python2.6/site-packages/setuptools-0.6c11-py2.6.egg-info']

3) I will consider upgrade to 2.7 post some more testing.

Thanks and regards
Dinesh
To post to this group, send email to robotframe...@googlegroups.com.

Pekka Klärck

unread,
Jan 6, 2017, 1:29:45 PM1/6/17
to kumar....@gmail.com, robotframework-users
Hello,

There seems to be something wrong in Python installation/configuration
on that machine. I'm fairly certain that this error occurs when Robot
tries to import ElementTree XML parsing modules it uses when parsing
output.xml files. You can test does `python -c "from xml.etree import
cElementTree"` work.

I wouldn't spent too much time trying to solve this problem with
Python 2.6 that you are using. It's not going to be supported by Robot
Framework 3.1 anymore, so installing Python 2.7 instead is probably a
better idea.

Cheers,
.peke
> --
> You received this message because you are subscribed to the Google Groups
> "robotframework-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to robotframework-u...@googlegroups.com.
> To post to this group, send email to robotframe...@googlegroups.com.
> Visit this group at https://groups.google.com/group/robotframework-users.
> For more options, visit https://groups.google.com/d/optout.



--
Agile Tester/Developer/Consultant :: http://eliga.fi
Lead Developer of Robot Framework :: http://robotframework.org
Reply all
Reply to author
Forward
0 new messages