Cannot install library without lxml being installed first

Sebastian Rahlf avatarSebastian Rahlf created an issue

Trying to install python-amazon-product-api in a clean site-packages directory (i.e. no lxml) results in

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "amazonproduct.py", line 54, in <module>
    from lxml import objectify
ImportError: No module named lxml

because setup.py tries to use amazonproduct.__version__ for which it needs to import that module first.

Comments (8)

  1. Sebastian Rahlf

    There are two solutions to remedy this problem:

    1. Hardcode the version number in setup.py
    2. Turn the module into a package (i.e. amazonproduct.py -> amazonproduct/api.py)
  2. Anonymous

    I'd really love to see this fixed; so far I've just been installing lxml first via pip when necessary.

  3. Vladimir Sanchez

    I just had the same issue while instantiating and API() class. It barfed with:

    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File "/sandbox/local/lib/python2.7/site-packages/amazonproduct/api.py", line 142, in __init__
        self.response_processor = processor or LxmlObjectifyProcessor()
      File "/sandbox/local/lib/python2.7/site-packages/amazonproduct/processors.py", line 24, in __init__
    from lxml import etree, objectify
    ImportError: No module named lxml
    

    I tried installing lxml in virtualenv and it was a pain due to missing header files and such. Have you had any such experiences ?

    Will appreciate any feedback.

  4. nhinkle

    I got this problem too, using version 2.6 of your API. The problem seems to be related to operating in a virtualenv. What you need to do is install libxml2-dev and libxslt-dev (using for example apt-get or similar), then do pip install lxml in your virtualenv. See this stack overflow post for some relevant details that helped me figure this out.

  5. Log in to comment
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.