load_dotenv doesn't find .env when run from LabVIEW
メンテナーはふだん 12 日以内に返信
まだ誰も着手していません。
評価
調査の方向性
Start with find_dotenv, especially its _is_interactive function, and compare its behavior when the Python script is run normally versus inside LabVIEW. Done means the .env file beside the script is found without passing an explicit path, while the existing load_dotenv and find_dotenv behavior remains intact.
索引モデルが issue の本文から書いたものです。
説明
I have a Python script that I'm running from LabVIEW using a Python node (LabVIEW's mechanism for running Python scripts inside a LabVIEW program).
I have .env file in the same directory with the Python script. However, when running the script from LabVIEW, load_dotenv() doesn't find .env, and neither does find_dotenv().
The culprit seems to be _is_interactive function inside find_dotenv:
def _is_interactive():
""" Decide whether this is running in a REPL or IPython notebook """
main = __import__('__main__', None, None, fromlist=['__file__'])
return not hasattr(main, '__file__')
When Python script is run inside LabVIEW, __name__ is set to the name of the Python module that is run, instead of __main__. Therefore, although __file__ is available and set properly when the script is run, and the script is actually not being run interactively, the above function returns true.
Consequently, .env is not searched for in the directory in which the script is located, but instead in the working directory, which in case of LabVIEW is C:\Windows\System32, and therefore cannot be found.
(I can work around the problem by passing the correct path manually to load_dotenv, but it would be great to have dotenv find the path automatically.)
- 主要言語
- Python
- スター
- 8.9k
- フォーク
- 618
- 平均マージ
- 12日 6分
- マージ済み PR(30日)
- 3
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
theskumar/python-dotenv のほかの issue
-
Variable declared without a value suppresses ${VAR:-default} expansion対応中かも @Omarinho12345 が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
theskumar/python-dotenv#750 ·
メンテナーはふだん 12 日以内に返信
-
An empty value ignores ${name:-default}対応中かも @SashaMIT が 41 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
theskumar/python-dotenv#715 ·
メンテナーはふだん 12 日以内に返信
-
set_key and unset_key don't fsync before replacing the .env file対応中かも @Imkkey が 40 日前に担当しました。 オープンenhancement
難易度 3/5 1〜2日 初心者へのやさしさ 72/100
theskumar/python-dotenv#713 ·
メンテナーはふだん 12 日以内に返信
-
難易度 5/5 1週間以上 初心者へのやさしさ 28/100
theskumar/python-dotenv#693 · コメント 1 件 ·
メンテナーはふだん 12 日以内に返信
-
python-dotenv installation without cli masks python-dotenv cli対応中かも @gyanu2507 が 80 日前に担当しました。 オープン
難易度 3/5 1〜2日 初心者へのやさしさ 55/100
theskumar/python-dotenv#683 · コメント 4 件 ·
メンテナーはふだん 12 日以内に返信
theskumar/python-dotenv の issue をすべて見る
似ている issue
-
release
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
MichaelYcJo/SpecSeal#1535 ·
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
valentinfrlch/ha-llmvision#769 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 1/5 1時間未満 初心者へのやさしさ 75/100
daniel-ospina/tortoise#11937 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
good first issue help wanted python up-for-grabs
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
andrewsiah/agentswarm-data-tasks#238 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
cadence-workflow/cadence-ai-samples#175 ·
メンテナーはふだん 1 日以内に返信