LoginSignup
6
8
記事投稿キャンペーン 「2024年!初アウトプットをしよう」

dmarc-visualizer を起動後 ModuleNotFoundError: No module named 'msgraph' が出て動かない時にすること

Last updated at Posted at 2024-01-25

はじめに

dmarc-visualizer を利用し DMARC レポートの集計を試みた。
諸々の設定が完了し起動してみたが ModuleNotFoundError: No module named 'msgraph' が発生し、dmarc-visualizer を起動できなかった。原因が分かったので回避策と理由を書き残しておきます。

出力されたエラー

dmarc-visualizer を起動すると下記エラーで終了してしまう。

Traceback (most recent call last):
  File "/usr/local/bin/parsedmarc", line 5, in <module>
    from parsedmarc.cli import _main
  File "/usr/local/lib/python3.9/site-packages/parsedmarc/__init__.py", line 31, in <module>
    from parsedmarc.mail import MailboxConnection
  File "/usr/local/lib/python3.9/site-packages/parsedmarc/mail/__init__.py", line 2, in <module>
    from parsedmarc.mail.graph import MSGraphConnection
  File "/usr/local/lib/python3.9/site-packages/parsedmarc/mail/graph.py", line 10, in <module>
    from msgraph.core import GraphClient
ModuleNotFoundError: No module named 'msgraph'

変更箇所

この修正方法は、dmarc-visualizer671b16a に有効であった。その他バージョン? コミットでは検証していない。

parsedmarc/Dockerfile
diff --git a/parsedmarc/Dockerfile b/parsedmarc/Dockerfile
index c2ea0cd..bfb5391 100644
--- a/parsedmarc/Dockerfile
+++ b/parsedmarc/Dockerfile
@@ -2,7 +2,7 @@ FROM python:3.9-alpine3.16

 RUN apk add --update --no-cache libxml2-dev libxslt-dev
 RUN apk add --update --no-cache --virtual .build_deps build-base libffi-dev \
-    && pip install parsedmarc \
+    && pip install parsedmarc msgraph-core==0.2.2 \
     && apk del .build_deps

 COPY parsedmarc.ini

変更の理由・背景

dmarc-visualizer は、 parsedmarcElasticsearchGrafana を利用している。
今回出ていたエラーは parsedmarc で発生している。 parsedmarc のレポジトリを確認したところすでに Issue が作成されていた。

I looked up the module name msgraph and found that it refers to the dependent package msgraph-core,
The latest version of msgraph-core, 1.0.0, was released on 2024-01-23, the first major release since 2021-07-27.

On the other hand, if you look at project.toml, you will see that >= 0.2.2.

parsedmarc/pyproject.toml
# Line 50 in 7d2b431
"msgraph-core>=0.2.2",

Therefore, it is assumed that a new installation of parsedmarc installs msgraph-core 1.0.0, and that it no longer works.

簡単に書くと .... 原因は module 'msgraph' の依存元である msgraph-core のメジャーリリースが2024年1月に行われた。parsedmarc の project.toml の定義では v0.2 ではなく、新しい v1 が取得されてしまい起動に失敗した。
ただ、原因はわかりましたが dmarc-visualizer に存在しない project.toml を編集することが不可能だったため parsedmarc/Dockerfile を編集することとした。

References

6
8
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
8