468,511 Members | 1,688 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,511 developers. It's quick & easy.

Have I broken my installation?

Hi folks,

I have an old Linux box that I am messing about with Python on. The
RedHat installed version is 1.5 something so I have built & installed
2.2.2 in /opt/python.

I've started trying to play with XML and ran into an error when
attempting to parse a document:
Traceback (most recent call last):
File "/mnt/hugedisk/share/MattsMovableType/stb/stb.cgi", line 90, in ?
documentElem = parse( rssFile )
File "/opt/python/lib/python2.2/xml/dom/minidom.py", line 962, in parse
return _doparse(pulldom.parse, args, kwargs)
File "/opt/python/lib/python2.2/xml/dom/minidom.py", line 953, in _doparse
events = apply(func, args, kwargs)
File "/opt/python/lib/python2.2/xml/dom/pulldom.py", line 328, in parse
parser = xml.sax.make_parser()
File "/opt/python/lib/python2.2/xml/sax/__init__.py", line 93, in make_parser
raise SAXReaderNotAvailable("No parsers found", None)
xml.sax._exceptions.SAXReaderNotAvailable: No parsers found
Googling around it seems like I needed to build XML support when I
built Python. I'm not sure what I should have done differently when I
built in order to make that happen. The other option on offer
appeared to be installing PyXML.

I duly downloaded PyXML 0.8.2 and installed it (again into /opt/python
using --prefix).

Now instead of the previous error I get a different problem entirely:
Traceback (most recent call last):
File "/mnt/hugedisk/share/MattsMovableType/stb/stb.cgi", line 18, in ?
from xml.dom.minidom import parse, Document
File "./xml.py", line 2, in ?
from xml.dom.minidom import parse
ImportError: No module named dom.minidom


I'm pretty sure I had a module dom.minidom before as it is the import
statement that is raising the exception and it didn't prior to
installing PyXML, I was previously calling parse() and Document().

So did I make a mistake installing PyXML? Can anyone advise me on
what my next steps should be?

Many thanks,

Matt

---
Systems Engineer, Hipbone(EMEA) Ltd.
3000 Hillswood drive, Chertsey, Surrey, KT16 0RS
Tel: 44-1932-895902 Mob: 44-7980-237-380
Jul 18 '05 #1
10 5345
Matt Mower <mm****@novissio.com> writes:
Googling around it seems like I needed to build XML support when I
built Python. I'm not sure what I should have done differently when I
built in order to make that happen.
You should have edited Modules/Setup, to activate pyexpat. Before
that, you probably should have installed a more recent Expat version
than the one shipped with Redhat.
Now instead of the previous error I get a different problem entirely:
Traceback (most recent call last):
File "/mnt/hugedisk/share/MattsMovableType/stb/stb.cgi", line 18, in ?
from xml.dom.minidom import parse, Document
File "./xml.py", line 2, in ?
from xml.dom.minidom import parse
ImportError: No module named dom.minidom


I'm pretty sure I had a module dom.minidom before as it is the import
statement that is raising the exception and it didn't prior to
installing PyXML, I was previously calling parse() and Document().

So did I make a mistake installing PyXML?


This is uncertain. Does this also happen when you invoke Python from
the command line? If so, what happens if you do

import xml
print xml
import xml.dom
print xml.dom
import xml.dom.minidom
print xml.dom.minidom

If not, what happens if you do the same in the CGI script?

Regards,
Martin
Jul 18 '05 #2
Hi Martin,

Thanks for responding. My answers are below.

On 28 Jun 2003 17:53:52 +0200, ma****@v.loewis.de (Martin v. Löwis)
wrote:
I'm pretty sure I had a module dom.minidom before as it is the import
statement that is raising the exception and it didn't prior to
installing PyXML, I was previously calling parse() and Document().

So did I make a mistake installing PyXML?


This is uncertain. Does this also happen when you invoke Python from
the command line? If so, what happens if you do

import xml
print xml
import xml.dom
print xml.dom
import xml.dom.minidom
print xml.dom.minidom


It turns out I made a bad choice naming my test program 'xml.py'. I
discovered that these commands failed in the directory I was working
on the script in, but succeeded elsewhere.

I guess I didn't realise that my local files could interfere with
importing from Pythons libraries. Stupid mistake on my part!

Thanks again!

Matt

---
Systems Engineer, Hipbone(EMEA) Ltd.
3000 Hillswood drive, Chertsey, Surrey, KT16 0RS
Tel: 44-1932-895902 Mob: 44-7980-237-380
Jul 18 '05 #3
Matt Mower <mm****@novissio.com> writes:
Nothing in the environment or access to the file system suggests to me
why it works as for my account but not for the nobody account.


So I'll ask my questions again: Print xml, xml.dom, xml.dom.minidom
both in the interactive mode and the CGI script.

Martin

Jul 18 '05 #4
Hi Martin,

On 28 Jun 2003 19:49:58 +0200, ma****@v.loewis.de (Martin v. Löwis)
wrote:
Matt Mower <mm****@novissio.com> writes:
Nothing in the environment or access to the file system suggests to me
why it works as for my account but not for the nobody account.


So I'll ask my questions again: Print xml, xml.dom, xml.dom.minidom
both in the interactive mode and the CGI script.


Sorry, sometimes I don't listen so good.

Interactively as user 'nobody':

|>>> import xml
|>>> print xml
|<module 'xml' from '/opt/python/lib/python2.2/xml/__init__.pyc'>
|>>> import xml.dom
|>>> print xml.dom
|<module 'xml.dom' from '/opt/python/lib/python2.2/xml/dom/__init__.pyc'>
|>>> import xml.dom.minidom
|>>> print xml.dom.minidom
|<module 'xml.dom.minidom' from '/opt/python/lib/python2.2/xml/dom/minidom.pyc'>

via CGI webserver running as user 'nobody':

|<module 'xml' from '/opt/python/lib/python2.2/xml/__init__.pyc'>
|<module 'xml.dom' from '/opt/python/lib/python2.2/xml/dom/__init__.pyc'>
|<module 'xml.dom.minidom' from '/opt/python/lib/python2.2/xml/dom/minidom.pyc'>

Regards,

Matt

---
Systems Engineer, Hipbone(EMEA) Ltd.
3000 Hillswood drive, Chertsey, Surrey, KT16 0RS
Tel: 44-1932-895902 Mob: 44-7980-237-380
Jul 18 '05 #5
Matt Mower <mm****@novissio.com> writes:
|>>> import xml
|>>> print xml
|<module 'xml' from '/opt/python/lib/python2.2/xml/__init__.pyc'>
|>>> import xml.dom
|>>> print xml.dom
|<module 'xml.dom' from '/opt/python/lib/python2.2/xml/dom/__init__.pyc'>
|>>> import xml.dom.minidom
|>>> print xml.dom.minidom
|<module 'xml.dom.minidom' from '/opt/python/lib/python2.2/xml/dom/minidom.pyc'>


And you said you have PyXML installed? This sounds unlikely: minidom
would come from site-packages/_xmlplus if you had.

Regards,
Martin
Jul 18 '05 #6
I think you should have installed a recent version of Expat.

-aj

--On Samstag, 28. Juni 2003 16:23 Uhr +0100 Matt Mower
<mm****@novissio.com> wrote:
Hi folks,

I have an old Linux box that I am messing about with Python on. The
RedHat installed version is 1.5 something so I have built & installed
2.2.2 in /opt/python.

I've started trying to play with XML and ran into an error when
attempting to parse a document:
Traceback (most recent call last):
File "/mnt/hugedisk/share/MattsMovableType/stb/stb.cgi", line 90, in ?
documentElem = parse( rssFile )
File "/opt/python/lib/python2.2/xml/dom/minidom.py", line 962, in parse
return _doparse(pulldom.parse, args, kwargs)
File "/opt/python/lib/python2.2/xml/dom/minidom.py", line 953, in
_doparse events = apply(func, args, kwargs)
File "/opt/python/lib/python2.2/xml/dom/pulldom.py", line 328, in parse
parser = xml.sax.make_parser()
File "/opt/python/lib/python2.2/xml/sax/__init__.py", line 93, in
make_parser raise SAXReaderNotAvailable("No parsers found", None)
xml.sax._exceptions.SAXReaderNotAvailable: No parsers found


Googling around it seems like I needed to build XML support when I
built Python. I'm not sure what I should have done differently when I
built in order to make that happen. The other option on offer
appeared to be installing PyXML.

I duly downloaded PyXML 0.8.2 and installed it (again into /opt/python
using --prefix).

Now instead of the previous error I get a different problem entirely:
Traceback (most recent call last):
File "/mnt/hugedisk/share/MattsMovableType/stb/stb.cgi", line 18, in ?
from xml.dom.minidom import parse, Document
File "./xml.py", line 2, in ?
from xml.dom.minidom import parse
ImportError: No module named dom.minidom


I'm pretty sure I had a module dom.minidom before as it is the import
statement that is raising the exception and it didn't prior to
installing PyXML, I was previously calling parse() and Document().

So did I make a mistake installing PyXML? Can anyone advise me on
what my next steps should be?

Many thanks,

Matt

---
Systems Engineer, Hipbone(EMEA) Ltd.
3000 Hillswood drive, Chertsey, Surrey, KT16 0RS
Tel: 44-1932-895902 Mob: 44-7980-237-380
--
http://mail.python.org/mailman/listinfo/python-list


Jul 18 '05 #7
Hi Martin,

On 28 Jun 2003 20:24:19 +0200, ma****@v.loewis.de (Martin v. Löwis)
wrote:
Matt Mower <mm****@novissio.com> writes:
|>>> import xml
|>>> print xml
|<module 'xml' from '/opt/python/lib/python2.2/xml/__init__.pyc'>
|>>> import xml.dom
|>>> print xml.dom
|<module 'xml.dom' from '/opt/python/lib/python2.2/xml/dom/__init__.pyc'>
|>>> import xml.dom.minidom
|>>> print xml.dom.minidom
|<module 'xml.dom.minidom' from '/opt/python/lib/python2.2/xml/dom/minidom.pyc'>


And you said you have PyXML installed? This sounds unlikely: minidom
would come from site-packages/_xmlplus if you had.


The installation instructions that came with my PyXML distro (0.8.2)
said to execute:

python setup.py build
python setup.py install

I made one small adjustment, specifying the --prefix=/opt/python
option to put PyXML in the same directory as Python 2.2.

My entire Python developing experience runs to about an afternoons
worth so I have no idea why PyXML isn't working or isn't being found.

Can you suggest anything?

Thanks,

Matt

---
Systems Engineer, Hipbone(EMEA) Ltd.
3000 Hillswood drive, Chertsey, Surrey, KT16 0RS
Tel: 44-1932-895902 Mob: 44-7980-237-380
Jul 18 '05 #8
On Sat, 28 Jun 2003 21:40:12 +0200, Andreas Jung
<li***@andreas-jung.com> wrote:
I think you should have installed a recent version of Expat.


You and Martin were both correct. This was the essential step.

|<module '_xmlplus' from '/opt/python/lib/python2.2/site-packages/_xmlplus/__init__.pyc'>
|<module 'xml.dom' from '/opt/python/lib/python2.2/site-packages/_xmlplus/dom/__init__.pyc'>
|<module 'xml.dom.minidom' from '/opt/python/lib/python2.2/site-packages/_xmlplus/dom/minidom.pyc'>

Which is what I think Martin was expecting to see earlier.

My thanks to you both.

Regards,

Matt

Jul 18 '05 #9
Matt Mower wrote:
Looks like I spoke a little too soon.

The minimal test script:

from xml.dom.minidom import parse, Document
doc = parse( "...some file..." )
print doc

works, spitting out a reference to a minidom instance.

However the CGI script which is, in a roundabout way, doing exactly
the same thing still comes up with the error:


Whenever there's a difference in behavior between a program in your
shell and in CGI (or someone else's shell), it's almost certainly a
difference in paths. You said that you installed some Python utilities
into some nonstandard places (like /opt/python); that's likely what your
problem is.

--
Erik Max Francis && ma*@alcyone.com && http://www.alcyone.com/max/
__ San Jose, CA, USA && 37 20 N 121 53 W && &tSftDotIotE
/ \ Every astronaut who goes up knows the risks he or she faces.
\__/ Sally Ride
Jul 18 '05 #10
Matt Mower wrote:
I made one small adjustment, specifying the --prefix=/opt/python
option to put PyXML in the same directory as Python 2.2.
Well, that's your problem right there. Note the symptomology of what
Martin von Loewis asked you to test -- it prints different things for
your interactive usage and the CGI script.
My entire Python developing experience runs to about an afternoons
worth so I have no idea why PyXML isn't working or isn't being found.
That's because the problem you're running into here is a difference in
environment between you running the program in your interactive shell
and Apache running it as nobody. It's a general Unix issue, not
specific to Python.
Can you suggest anything?


The problem is that you've installed PyXML in /opt/python, which is a
nonstandard place -- though that isn't in and of itself wrong if you
know what you're doing. You've obviously adjusted your interactive
environment to look in /opt/python, since you're running the scripts
without problems locally, but CGI scripts do not run in your
environment, and so aren't seeing what you've installed in /opt/python,
since that is a nonstandard place. For a quick remedy, add something
like this:

import sys
sys.path.append('/opt/python')

to the top of your script. A more permanent solution would involve
adding it to /usr/local/lib/pythonX.Y/site.py.

--
Erik Max Francis && ma*@alcyone.com && http://www.alcyone.com/max/
__ San Jose, CA, USA && 37 20 N 121 53 W && &tSftDotIotE
/ \ Every astronaut who goes up knows the risks he or she faces.
\__/ Sally Ride
Jul 18 '05 #11

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Michał Januszczyk | last post: by
15 posts views Thread by Jake | last post: by
87 posts views Thread by Sony Music CDs install Malware | last post: by
13 posts views Thread by Steven Bethard | last post: by
9 posts views Thread by Endless Story | last post: by
2 posts views Thread by Bruno Rezende | last post: by
5 posts views Thread by Larry Bates | last post: by
1 post views Thread by fmendoza | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.