load_dotenv doesn't find .env when run from LabVIEW
Maintainers usually reply within 12 days
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 45/100
Research direction
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.
Written by the indexing model from the issue text.
Description
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.)
- Dominant language
- Python
- Stars
- 8.9k
- Forks
- 618
- Avg merge
- 12d 6m
- Merged PRs (30d)
- 3
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from theskumar/python-dotenv
-
Variable declared without a value suppresses ${VAR:-default} expansionPossibly taken @Omarinho12345 claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
theskumar/python-dotenv#750 ·
Maintainers usually reply within 12 days
-
An empty value ignores ${name:-default}Possibly taken @SashaMIT claimed this 41 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
theskumar/python-dotenv#715 ·
Maintainers usually reply within 12 days
-
set_key and unset_key don't fsync before replacing the .env filePossibly taken @Imkkey claimed this 40 days ago. Openenhancement
Difficulty 3/5 1-2 days Newbie friendliness 72/100
theskumar/python-dotenv#713 ·
Maintainers usually reply within 12 days
-
Difficulty 5/5 Over a week Newbie friendliness 28/100
theskumar/python-dotenv#693 · 1 comment ·
Maintainers usually reply within 12 days
-
python-dotenv installation without cli masks python-dotenv cliPossibly taken @gyanu2507 claimed this 80 days ago. Open
Difficulty 3/5 1-2 days Newbie friendliness 55/100
theskumar/python-dotenv#683 · 4 comments ·
Maintainers usually reply within 12 days
All issues in theskumar/python-dotenv
Similar issues
-
release
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
MichaelYcJo/SpecSeal#1535 ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
valentinfrlch/ha-llmvision#769 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 1/5 Under an hour Newbie friendliness 75/100
daniel-ospina/tortoise#11937 · 1 comment ·
Maintainers usually reply within 1 day
-
good first issue help wanted python up-for-grabs
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
andrewsiah/agentswarm-data-tasks#238 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
cadence-workflow/cadence-ai-samples#175 ·
Maintainers usually reply within 1 day