pip install openpyxl fails

Issue #253 resolved
Anonymous created an issue

Ubuntu 10.04, Python 2.6.5.

File "openpyxl/shared/init.py", line 31, in <module>

from openpyxl.shared import xmltools

File "openpyxl/shared/xmltools.py", line 74, in <module>

from lxml.etree import (

ImportError: cannot import name register_namespace

Comments (15)

  1. CharlieC

    It looks like there is something wrong with your installation. There is no file openpyxl/shared/init.py

    Otherwise, it may be that you have an outdated version of lxml on your system. You can avoid problems with this by using a virtualenv.

    charlie@mail:~/tmp$ virtualenv gg
    New python executable in gg/bin/python
    Installing distribute..................................................................................................................................................................................done.
    charlie@mail:~/tmp$ cd gg
    charlie@mail:~/tmp/gg$ source bin/activate
    (gg)charlie@mail:~/tmp/gg$ python
    Python 2.6.6 (r266:84292, Dec 26 2010, 22:31:48) 
    [GCC 4.4.5] on linux2
    Type "help", "copyright", "credits" or "license" for more information.
    >>> 
    (gg)charlie@mail:~/tmp/gg$ pip install openpyxl
    Downloading/unpacking openpyxl
      Downloading openpyxl-1.8.1.tar.gz (78Kb): 78Kb downloaded
      Running setup.py egg_info for package openpyxl
        no previously-included directories found matching 'openpyxl/tests'
        no previously-included directories found matching 'openpyxl/sample'
    Installing collected packages: openpyxl
      Running setup.py install for openpyxl
        no previously-included directories found matching 'openpyxl/tests'
        no previously-included directories found matching 'openpyxl/sample'
    Successfully installed openpyxl
    Cleaning up...
    (gg)charlie@mail:~/tmp/gg$ python
    Python 2.6.6 (r266:84292, Dec 26 2010, 22:31:48) 
    [GCC 4.4.5] on linux2
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import openpyxl
    

    We will be adding a check on the lxmlversion so that versions < 3.2.5 will not be recognised.

  2. bob_haugen

    Thanks for the response and the lxml version check.

    Already using a virtualenv. It's pretty old, though, maybe it has some old crap in it. I'll set up a new one and try again.

  3. CharlieC

    Okay, we'll have to dig a bit deeper into this. In the meantime as a workaround I can only suggest that you install lxml in the virtualenv and then openpyxl. I'm going to look at a Ubuntu VM (the current version is 13.04) to see if I can replicate your problem.

  4. bob_haugen

    Ok, this might be the source of the problem: ~/.virtualenvs/vn5$ pip install lxml Requirement already satisfied (use --upgrade to upgrade): lxml in /usr/lib/python2.6/dist-packages

  5. CharlieC

    Yep. You need to recreate the virtualenv --with-no-site-packages. This has been the default for a while now as system libraries, particularly on Debian usually conflict with the versions required by applications. Note, this might mean you have to install the python-dev package as well as libxml2 so that lxml can be compiled.

    1.8.2 should at least reduce the problems associated with this by checking the version of lxml. But I'll also add a note to the documentation.

  6. bob_haugen

    Charlie, thank you very much for sticking through this with me, especially given my cluelessness.

    Upgrading virtualenv and then creating a new one fixed the problem. pip install openpyxl now works. Please change the status of this issue to resolved.

  7. CharlieC

    Well, not entirely. Virtualenv used to keep system packages by default and sometimes you need the option. But supporting old versions of OS (especially Linux distros and of these especially RedHat) can be really difficult. Is 10.04 still supported by Canonical?

    MacOS is not quite as bad - faster upgrade cycle - but also because it's easy to tell people not to use the packages that Apple provides but doesn't maintain

  8. bob_haugen

    Yes, 10.04 is still supported. I don't upgrade because then I get a new desktop that screws up my workflow, unless I do a bunch of tinkering. Will need to upgrade sooner or later, or maybe go to a different distro. But I'm just trying to get my work done...which is django programming.

  9. Log in to comment