Fixing ImportError: DLL load failed: The specified procedure could not be found. for conda installed exchangelib in virtual environment

Viewed 600

I am using Python version 3.7.9 installed using anaconda. I want to use the exchangelib package. I installed it using conda install:

conda install -c conda-forge exchangelib

However, when I try to import exchangelib into a Python script, using the obvious line

import exchangelib

I get the following error:

Traceback (most recent call last):
  File "main.py", line 26, in <module>
    import exchangelib
  File "C:\Users\SE78489\Anaconda3\envs\tf\lib\site-packages\exchangelib\__init__.py", line 3, in <module>
    from .account import Account, Identity
  File "C:\Users\SE78489\Anaconda3\envs\tf\lib\site-packages\exchangelib\account.py", line 6, in <module>
    from .autodiscover import discover
  File "C:\Users\SE78489\Anaconda3\envs\tf\lib\site-packages\exchangelib\autodiscover\__init__.py", line 1, in <module>
    from .cache import AutodiscoverCache, autodiscover_cache
  File "C:\Users\SE78489\Anaconda3\envs\tf\lib\site-packages\exchangelib\autodiscover\cache.py", line 11, in <module>
    from ..configuration import Configuration
  File "C:\Users\SE78489\Anaconda3\envs\tf\lib\site-packages\exchangelib\configuration.py", line 6, in <module>
    from .protocol import RetryPolicy, FailFast
  File "C:\Users\SE78489\Anaconda3\envs\tf\lib\site-packages\exchangelib\protocol.py", line 21, in <module>
    from .properties import FreeBusyViewOptions, MailboxData, TimeWindow, TimeZone
  File "C:\Users\SE78489\Anaconda3\envs\tf\lib\site-packages\exchangelib\properties.py", line 10, in <module>
    from .fields import SubField, TextField, EmailAddressField, ChoiceField, DateTimeField, EWSElementField, MailboxField, \
  File "C:\Users\SE78489\Anaconda3\envs\tf\lib\site-packages\exchangelib\fields.py", line 11, in <module>
    from .ewsdatetime import EWSDateTime, EWSDate, EWSTimeZone, NaiveDateTimeNotAllowed, UnknownTimeZone, UTC
  File "C:\Users\SE78489\Anaconda3\envs\tf\lib\site-packages\exchangelib\ewsdatetime.py", line 12, in <module>
    from .winzone import IANA_TO_MS_TIMEZONE_MAP, MS_TIMEZONE_TO_IANA_MAP
  File "C:\Users\SE78489\Anaconda3\envs\tf\lib\site-packages\exchangelib\winzone.py", line 7, in <module>
    from .util import to_xml
  File "C:\Users\SE78489\Anaconda3\envs\tf\lib\site-packages\exchangelib\util.py", line 17, in <module>
    import lxml.etree  # nosec
ImportError: DLL load failed: The specified procedure could not be found.

How do I fix this?

It may help to know that I installed exchangelib inside a virtual environment, created using conda, and that I am working on a virtual machine. This is where I had the problem. I tried installing and importing on my local machine in the base environment, and it worked fine.

0 Answers
Related