python-caldav / caldav

Apache License 2.0
321 stars 95 forks source link

Error importing from lxml #378

Closed seanmills1020 closed 8 months ago

seanmills1020 commented 8 months ago

Hello,

I have my Python script working locally, but when I try running it in a production environment, I get the following error:

Traceback (most recent call last):
  File "/opt/FileMaker/FileMaker Server/Data/Scripts/test-caldav.py", line 12, in <module>
    import caldav
  File "/usr/local/lib/python3.8/dist-packages/caldav/__init__.py", line 8, in <module>
    from .davclient import DAVClient
  File "/usr/local/lib/python3.8/dist-packages/caldav/davclient.py", line 7, in <module>
    from caldav.elements import cdav
  File "/usr/local/lib/python3.8/dist-packages/caldav/elements/cdav.py", line 18, in <module>
    from .base import BaseElement, NamedBaseElement, ValuedBaseElement
  File "/usr/local/lib/python3.8/dist-packages/caldav/elements/base.py", line 5, in <module>
    from lxml import etree
ImportError: cannot import name 'etree' from 'lxml' (/usr/local/lib/python3.8/dist-packages/lxml/__init__.py)

FWIW, even though the path to the caldav library references Python 3.8, the server is running Python 3.9.5.

Any ideas?

tobixen commented 8 months ago

It fails loading lxml.etree. The etree-part is not python code, but compiled, so if it's compiled for 3.8, then it will not run under python 3.9.

Somehow your python environment is a bit messed up, rather than having python 3.9 loading modules from /usr/local/lib/python3.8/ you should reinstall all the modules under /usr/local/lib/python3.9/