Seite 1 von 1

Read Mail vom Exchange-Server

Verfasst: Donnerstag 3. März 2022, 16:58
von Musiker123
Hallo zusammen,
wollte einmal die INBOX von meinem Mail-Account auslesen.
unter Pycharm funktioniert der Code auch einwandfrei.
wenn ich das Programm per py2exe compiliere kriege ich Fehler.
Kann mir jemand helfen?
Hier der Code:

from exchangelib import Credentials, Account
import elementpath
from xml.etree import ElementTree

user = 'xxxxx.yyyyy.de'
pw ='abcedf'
credentials = Credentials(user, pw)
try:
account = Account(user, credentials=credentials, autodiscover=True)

for item in account.inbox.all().order_by('-datetime_received')[:10]:
print(item.subject, item.sender, item.datetime_received)
except:
input ('leider Fehler')
-----


Hier die Fehlermeldung:
--
Traceback (most recent call last):
File "EDIMail2a.py", line 1, in <module>
File "c:\users\rcc ulc\appdata\local\programs\python\python39\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 476, in exec_module
exec(bytecode, module.__dict__)
File "exchangelib\__init__.py", line 1, in <module>
File "c:\users\rcc ulc\appdata\local\programs\python\python39\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 476, in exec_module
exec(bytecode, module.__dict__)
File "exchangelib\account.py", line 6, in <module>
File "c:\users\rcc ulc\appdata\local\programs\python\python39\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 476, in exec_module
exec(bytecode, module.__dict__)
File "exchangelib\autodiscover\__init__.py", line 1, in <module>
File "c:\users\rcc ulc\appdata\local\programs\python\python39\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 476, in exec_module
exec(bytecode, module.__dict__)
File "exchangelib\autodiscover\cache.py", line 11, in <module>
File "c:\users\rcc ulc\appdata\local\programs\python\python39\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 476, in exec_module
exec(bytecode, module.__dict__)
File "exchangelib\configuration.py", line 7, in <module>
File "c:\users\rcc ulc\appdata\local\programs\python\python39\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 476, in exec_module
exec(bytecode, module.__dict__)
File "exchangelib\protocol.py", line 31, in <module>
File "c:\users\rcc ulc\appdata\local\programs\python\python39\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 476, in exec_module
exec(bytecode, module.__dict__)
File "exchangelib\properties.py", line 11, in <module>
File "c:\users\rcc ulc\appdata\local\programs\python\python39\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 476, in exec_module
exec(bytecode, module.__dict__)
File "exchangelib\fields.py", line 8, in <module>
File "c:\users\rcc ulc\appdata\local\programs\python\python39\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 476, in exec_module
exec(bytecode, module.__dict__)
File "exchangelib\ewsdatetime.py", line 12, in <module>
File "c:\users\rcc ulc\appdata\local\programs\python\python39\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 476, in exec_module
exec(bytecode, module.__dict__)
File "exchangelib\winzone.py", line 7, in <module>
File "c:\users\rcc ulc\appdata\local\programs\python\python39\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 476, in exec_module
exec(bytecode, module.__dict__)
File "exchangelib\util.py", line 17, in <module>
File "src\lxml\etree.pyx", line 74, in init lxml.etree
ImportError: cannot import name _elementpath
[7048] Failed to execute script 'EDIMail2a' due to unhandled exception!

Re: Read Mail vom Exchange-Server

Verfasst: Donnerstag 3. März 2022, 21:53
von Dennis89
Hallo,

schau mal, hilft dir das weiter?
https://stackoverflow.com/questions/221 ... mporterror

Schau mal in das neu erstellte Verzeichnis, kannst du darin 'elementpath' finden? Wenn nicht, würde ich mal die 'include'-Option beim erstellen der *.exe versuchen.

Grüße
Dennis

Re: Read Mail vom Exchange-Server

Verfasst: Samstag 12. März 2022, 12:03
von Musiker123
Hallo Dennis,
erst einmal vielen Dank für die Info.
Ich arbeite mit der GUI des pyinstallers 'auto-py-to-exe'
kannst Du mir sagen wo ich hier die include-Option angeben kann?
ich habe das ganze Netz durchsucht, aber nichts gefunden.
ich kann leider auch auf der Webseite des pyinstallers nicht hierzu finden
Vielen Dank vorab.
Rudi

Re: Read Mail vom Exchange-Server

Verfasst: Samstag 12. März 2022, 14:18
von Musiker123
danke gefunden : ---collect-submodules=elementpath 😊