2

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.

Brandon
  • 55
  • 3
  • This is a problem with lxml, not exchangelib. You would probably see the same if you did `conda install -c conda-forge lxml` and then `import lxml`. – Erik Cederstrand Jan 06 '21 at 08:17
  • Does this answer your question? [lxml installed with conda: "ImportError: DLL load failed: The specified procedure could not be found"](https://stackoverflow.com/questions/54075542/lxml-installed-with-conda-importerror-dll-load-failed-the-specified-procedur) – Erik Cederstrand Jan 06 '21 at 12:39
  • @ErikCederstrand Thank you for responding to my question and for pointing out the problem with lxml. Per the answer on the page that you linked, I checked the folder C:\Windows\System32\ on the virtual machine and it did indeed have those two dll files. I also checked on my local machine and I don't have those files, which explains why I was able to import exchangelib there. I would like to follow the suggestion on the other page and remove the files, but I can't remove them because I don't have admin privileges, so I can't tell if your suggestion really solves my problem. – Brandon Jan 07 '21 at 01:11

0 Answers0