Have I broken my installation?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Matt Mower

    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:
    [color=blue]
    >Traceback (most recent call last):
    > File "/mnt/hugedisk/share/MattsMovableTyp e/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(pulldo m.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_pa rser()
    > File "/opt/python/lib/python2.2/xml/sax/__init__.py", line 93, in make_parser
    > raise SAXReaderNotAva ilable("No parsers found", None)
    >xml.sax._excep tions.SAXReader NotAvailable: No parsers found[/color]

    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:
    [color=blue]
    >Traceback (most recent call last):
    > File "/mnt/hugedisk/share/MattsMovableTyp e/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[/color]

    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
  • Martin v. Löwis

    #2
    Re: Have I broken my installation?

    Matt Mower <mmower@novissi o.com> writes:
    [color=blue]
    > 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.[/color]

    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.
    [color=blue]
    > Now instead of the previous error I get a different problem entirely:
    >[color=green]
    > >Traceback (most recent call last):
    > > File "/mnt/hugedisk/share/MattsMovableTyp e/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[/color]
    >
    > 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?[/color]

    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

    Comment

    • Matt Mower

      #3
      Re: Have I broken my installation?

      Hi Martin,

      Thanks for responding. My answers are below.

      On 28 Jun 2003 17:53:52 +0200, martin@v.loewis .de (Martin v. Löwis)
      wrote:
      [color=blue][color=green]
      >> 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?[/color]
      >
      >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
      >[/color]

      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

      Comment

      • Martin v. Löwis

        #4
        Re: Have I broken my installation?

        Matt Mower <mmower@novissi o.com> writes:
        [color=blue]
        > 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.[/color]

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

        Martin

        Comment

        • Matt Mower

          #5
          Re: Have I broken my installation?

          Hi Martin,

          On 28 Jun 2003 19:49:58 +0200, martin@v.loewis .de (Martin v. Löwis)
          wrote:
          [color=blue]
          >Matt Mower <mmower@novissi o.com> writes:
          >[color=green]
          >> 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.[/color]
          >
          >So I'll ask my questions again: Print xml, xml.dom, xml.dom.minidom
          >both in the interactive mode and the CGI script.
          >[/color]

          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.minido m' 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.minido m' 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

          Comment

          • Martin v. Löwis

            #6
            Re: Have I broken my installation?

            Matt Mower <mmower@novissi o.com> writes:
            [color=blue]
            > |>>> 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.minido m' from '/opt/python/lib/python2.2/xml/dom/minidom.pyc'>[/color]

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

            Regards,
            Martin

            Comment

            • Andreas Jung

              #7
              Re: Have I broken my installation?

              I think you should have installed a recent version of Expat.

              -aj

              --On Samstag, 28. Juni 2003 16:23 Uhr +0100 Matt Mower
              <mmower@novissi o.com> wrote:
              [color=blue]
              > 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:
              >[color=green]
              >> Traceback (most recent call last):
              >> File "/mnt/hugedisk/share/MattsMovableTyp e/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(pulldo m.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_pa rser()
              >> File "/opt/python/lib/python2.2/xml/sax/__init__.py", line 93, in
              >> make_parser raise SAXReaderNotAva ilable("No parsers found", None)
              >> xml.sax._except ions.SAXReaderN otAvailable: No parsers found[/color]
              >
              > 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:
              >[color=green]
              >> Traceback (most recent call last):
              >> File "/mnt/hugedisk/share/MattsMovableTyp e/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[/color]
              >
              > 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[/color]





              Comment

              • Matt Mower

                #8
                Re: Have I broken my installation?

                Hi Martin,

                On 28 Jun 2003 20:24:19 +0200, martin@v.loewis .de (Martin v. Löwis)
                wrote:
                [color=blue]
                >Matt Mower <mmower@novissi o.com> writes:
                >[color=green]
                >> |>>> 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.minido m' from '/opt/python/lib/python2.2/xml/dom/minidom.pyc'>[/color]
                >
                >And you said you have PyXML installed? This sounds unlikely: minidom
                >would come from site-packages/_xmlplus if you had.
                >[/color]

                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

                Comment

                • Matt Mower

                  #9
                  Re: Have I broken my installation?

                  On Sat, 28 Jun 2003 21:40:12 +0200, Andreas Jung
                  <lists@andrea s-jung.com> wrote:
                  [color=blue]
                  >I think you should have installed a recent version of Expat.
                  >[/color]

                  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.minido m' 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

                  Comment

                  • Erik Max Francis

                    #10
                    Re: Have I broken my installation?

                    Matt Mower wrote:
                    [color=blue]
                    > 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:[/color]

                    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 && max@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

                    Comment

                    • Erik Max Francis

                      #11
                      Re: Have I broken my installation?

                      Matt Mower wrote:
                      [color=blue]
                      > I made one small adjustment, specifying the --prefix=/opt/python
                      > option to put PyXML in the same directory as Python 2.2.[/color]

                      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.
                      [color=blue]
                      > 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.[/color]

                      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.
                      [color=blue]
                      > Can you suggest anything?[/color]

                      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 && max@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

                      Comment

                      Working...