theskumar / theskumar/python-dotenv

ModuleNotFoundError: No module named '__main__' / load_dotenv() error on the latest Azure Functions (Python 3.9, Linux)

オープン
#419 コメント 5 件 リアクション 4 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

主要言語
Python
スター
8.9k
フォーク
581
PR マージ指標
30日以内にマージされた PR はありません

説明

dotenv.load_dotenv() caused ModuleNotFoundError: No module named '__main__' on the latest Azure Functions Python 3.9 environment (used as HTTP Trigger).

This is happening when use find_dotenv() internally, so this can be fixed by specifying env path like below.

envpath = os.path.join(os.path.dirname(__file__), '.env')
dotenv.load_dotenv(envpath)

(Issue #299 is maybe similar.)

Error logs:

Result: Failure Exception: ModuleNotFoundError: No module named '__main__' Stack: File "/azure-functions-host/workers/python/3.9/LINUX/X64/azure_functions_worker/dispatcher.py", line 448, in _handle__invocation_request call_result = await self._loop.run_in_executor( File "/usr/local/lib/python3.9/concurrent/futures/thread.py", line 58, in run result = self.fn(*self.args, **self.kwargs) File "/azure-functions-host/workers/python/3.9/LINUX/X64/azure_functions_worker/dispatcher.py", line 691, in _run_sync_func return ExtensionManager.get_sync_invocation_wrapper(context, File "/azure-functions-host/workers/python/3.9/LINUX/X64/azure_functions_worker/extension.py", line 215, in _raw_invocation_wrapper result = function(**args) File "/home/site/wwwroot/HttpTrigger_jetson_01_test/__init__.py", line 43, in main container_client = adls.get_container_client(place_name) File "/home/site/wwwroot/adls.py", line 14, in get_container_client dotenv.load_dotenv() File "/home/site/wwwroot/.python_packages/lib/site-packages/dotenv/main.py", line 322, in load_dotenv dotenv_path = find_dotenv() File "/home/site/wwwroot/.python_packages/lib/site-packages/dotenv/main.py", line 275, in find_dotenv if usecwd or _is_interactive() or getattr(sys, 'frozen', False): File "/home/site/wwwroot/.python_packages/lib/site-packages/dotenv/main.py", line 272, in _is_interactive main = __import__('__main__', None, None, fromlist=['__file__'])

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

Start with the find_dotenv() and load_dotenv() entry points shown in dotenv/main.py, then reproduce the failure in the Azure Functions Python 3.9 environment described. Verify that loading the environment file no longer raises ModuleNotFoundError for main, while the existing path-discovery behavior remains usable.

索引モデルが issue の本文から書いたものです。

評価

技術スタック
azure, python
領域
backend, cloud
issue の種類
バグ
難易度
3/5
見積もり時間
1〜2日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
35/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。