Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 925641
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T19:33:11+00:00 2026-05-15T19:33:11+00:00

I’d like to use lxml library to validate XML Schemas in Python 3.1.2. Since

  • 0

I’d like to use lxml library to validate XML Schemas in Python 3.1.2.

Since the Snow Leopard MAC OS comes with the Python 2.6.1 installed, firstly, I downloaded the Python 3.1.2 automated installer at http://www.python.org/ftp/python/3.1.2/python-3.1.2-macosx10.3-2010-03-24.dmg and installed it.

Secondly, I downloaded lxml 2.2.6 at http://pypi.python.org/packages/source/l/lxml/lxml-2.2.6.tar.gz, unpacked it and performed the installation as stated in http://wiki.python.org/moin/CheeseShopTutorial (i.e.:)

  $ cd lxml-2.2.6
  $ python setup.py install

It installed the package with no troubles at my Python 2.6 distribution site-packages directory (/Library/Python/2.6/site-packages), but I’d like to have it installed in my Python 3.1 distribution site-packages directory (/Library/Frameworks/Python.framework/Versions/3.1/lib/python3.1/site-packages).

I tried to replace python setup.py install with python3 setup.py install, but I’ve got a lot of error messages in the console. Installing the lxml by using easy_install lxml had the same effect.

As a last resort, I tried simply to move the content of the Python 2.6 distribution site-packages directory to the Python 3.1 distribution site-packages directory and run a test script like this:

try:
    from lxml import etree
    print("running with lxml.etree")
except ImportError:
    try:
        # Python 2.5
        import xml.etree.cElementTree as etree
        print("running with cElementTree on Python 2.5+")
    except ImportError:
        try:
            # Python 2.5
            import xml.etree.ElementTree as etree
            print("running with ElementTree on Python 2.5+")
        except ImportError:
            try:
                # normal cElementTree install
                import cElementTree as etree
                print("running with cElementTree")
            except ImportError:
                try:
                    # normal ElementTree install
                    import elementtree.ElementTree as etree
                    print("running with ElementTree")
                except ImportError:
                    print("Failed to import ElementTree from any known place")


schema_root = etree.parse('note.xsd').getroot()
schema = etree.XMLSchema(schema_root)
parser = etree.XMLParser(schema = schema)
root = etree.parse('note.xml', parser)

And I got this error message in the console:

Traceback (most recent call last):
  File "/Users/eduardo/Workspace/PythonToolbox/TestProject/src/testproject/domparse.py", line 97, in <module>
    schema = etree.XMLSchema(schema_root)
AttributeError: 'module' object has no attribute 'XMLSchema'
running with cElementTree on Python 2.5+

As suggested by Ned Deily, I did the following:

$ curl http://pypi.python.org/packages/source/l/lxml/lxml-2.2.6.tar.gz | tar xz 
$ cd lxml-2.2.6
$ python3 setup.py install

But I’ve got some compiler error messages, the file http://www.educoelho.com/files/output.txt

How can I get lxml running in Python 3.1?

Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T19:33:12+00:00Added an answer on May 15, 2026 at 7:33 pm

    If you are going to build lxml from source, you need to build it entirely with the desired Python. And, in general, you cannot just move site-packages from one Python instance to another, especially Python 2 vs Python 3. First, undo whatever copy or move you did into the Python 3 site-packages directory. If you are not sure what you did, you should consider re-installing Python 3.1. Now start with a clean copy of the lxml source from the tar file and try building it with python3.1:

    $ rm -r lxml-2.2.6
    $ curl http://pypi.python.org/packages/source/l/lxml/lxml-2.2.6.tar.gz | tar xz 
    $ cd lxml-2.2.6
    $ python3 setup.py install
    

    If you get errors, update your question to show exactly what error messages appear.

    EDIT: The relevant error message is this one:

    Compiling with an SDK that doesn't seem to exist: /Developer/SDKs/MacOSX10.4u.sdk
    

    Most python.org pythons are built to work on several versions of OS X so they use the optional 10.4 SDK. Apple’s Xcode installer for 10.6 Snow Leopard includes the 10.4u SDK but it is not installed by default. You need to install it using the Xcode installer (on the Snow Leopard DVD or that came with a new Mac or download from the Apple Developer Connection).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 463k
  • Answers 463k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Cairngorm 3 is NOT a framework. See my answer here May 16, 2026 at 12:43 am
  • Editorial Team
    Editorial Team added an answer When moving from one computer to another did you take… May 16, 2026 at 12:43 am
  • Editorial Team
    Editorial Team added an answer If you use ^com_bookmanagement= it will only match if com_bookmanagement=… May 16, 2026 at 12:43 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.