theskumar / theskumar/python-dotenv

load_dotenv doesn't find .env when run from LabVIEW

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

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

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

説明

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.)

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

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

はじめの一歩

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

調査の方向性

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 の本文から書いたものです。

評価

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

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

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