load_dotenv doesn't find .env when run from LabVIEW
Maintainer antworten meist innerhalb von 12 Tagen
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Anfängerfreundlichkeit
- 45/100
Rechercherichtung
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.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
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.)
- Vorherrschende Sprache
- Python
- Sterne
- 8.9k
- Forks
- 618
- Ø Merge
- 12 T. 6 Min.
- Gemergte PRs (30 T.)
- 3
Entwicklungsumgebung
- Kein Dockerfile und keine Docker-Compose-Datei
- Keine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus theskumar/python-dotenv
-
Variable declared without a value suppresses ${VAR:-default} expansionEvtl. vergeben @Omarinho12345 hat das heute übernommen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 85/100
theskumar/python-dotenv#750 ·
Maintainer antworten meist innerhalb von 12 Tagen
-
An empty value ignores ${name:-default}Evtl. vergeben @SashaMIT hat das vor 41 Tagen übernommen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 75/100
theskumar/python-dotenv#715 ·
Maintainer antworten meist innerhalb von 12 Tagen
-
set_key and unset_key don't fsync before replacing the .env fileEvtl. vergeben @Imkkey hat das vor 40 Tagen übernommen. Offenenhancement
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 72/100
theskumar/python-dotenv#713 ·
Maintainer antworten meist innerhalb von 12 Tagen
-
Schwierigkeit 5/5 Über eine Woche Anfängerfreundlichkeit 28/100
theskumar/python-dotenv#693 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 12 Tagen
-
python-dotenv installation without cli masks python-dotenv cliEvtl. vergeben @gyanu2507 hat das vor 80 Tagen übernommen. Offen
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 55/100
theskumar/python-dotenv#683 · 4 Kommentare ·
Maintainer antworten meist innerhalb von 12 Tagen
Alle Issues in theskumar/python-dotenv
Ähnliche Issues
-
release
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 76/100
MichaelYcJo/SpecSeal#1535 ·
-
bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 82/100
valentinfrlch/ha-llmvision#769 ·
Maintainer antworten meist innerhalb von 1 Tag
-
bug
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 75/100
daniel-ospina/tortoise#11937 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
good first issue help wanted python up-for-grabs
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 82/100
andrewsiah/agentswarm-data-tasks#238 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 70/100
cadence-workflow/cadence-ai-samples#175 ·
Maintainer antworten meist innerhalb von 1 Tag