question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

KeyError: 'PATH' on import in interactive window

See original GitHub issue

Trying

import xgboost

in the interactive window throws

/usr/local/Caskroom/miniconda/base/envs/thermo/lib/python3.6/site-packages/xgboost/__init__.py in 
      9 import os
     10 
---> 11 from .core import DMatrix, Booster
     12 from .training import train, cv
     13 from . import rabit                   # noqa

/usr/local/Caskroom/miniconda/base/envs/thermo/lib/python3.6/site-packages/xgboost/core.py in 
    134 
    135 # load the XGBoost library globally
--> 136 _LIB = _load_lib()
    137 
    138 

/usr/local/Caskroom/miniconda/base/envs/thermo/lib/python3.6/site-packages/xgboost/core.py in _load_lib()
    118     if len(lib_paths) == 0:
    119         return None
--> 120     pathBackup = os.environ['PATH']
    121     for lib_path in lib_paths:
    122         try:

/usr/local/Caskroom/miniconda/base/envs/thermo/lib/python3.6/os.py in __getitem__(self, key)
    667         except KeyError:
    668             # raise KeyError with the original key value
--> 669             raise KeyError(key) from None
    670         return self.decodevalue(value)
    671 

KeyError: 'PATH'

but works fine in terminal.

As suggested by @bbcCorp in microsoft/vscode-python#436, I tried creating a .env file with

echo "PATH=\$PATH" >> .env

but the issue persists. I’m running the latest VS Code and insider’s build of the Python extension.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:12 (12 by maintainers)

github_iconTop GitHub Comments

1reaction
janoshcommented, Dec 20, 2019

@DonJayamanne Just tested this again and all is back to working now with the insider’s. Thanks a lot! 👍

0reactions
DonJayamannecommented, Dec 20, 2019

@janosh thanks for testing the insiders and getting back.

Read more comments on GitHub >

github_iconTop Results From Across the Web

KeyError: 'PATH' on import in interactive window #2589 - GitHub
I'm running the latest VS Code and insider's build of the Python extension. Python Ext Version: 2019.12.53195-dev. VS Code Version: 1.40.2 ...
Read more >
KeyError 'PATH' on numpy Import - python - Stack Overflow
It seems that this is an issue which is already fixed but the fix is not released yet: Issue in numpy github repo...
Read more >
How to fix Python KeyError Exceptions in simple steps?
Whenever an exception is raised in Python, it is done using traceback, as you can see in the example code above.
Read more >
Key Error: os.environ["HOME"] - Python Forum
I run the python script in python3.8 and this return an key error. Error: ... Windows doesn't have HOME ... import os. print...
Read more >
What's New In Python 3.8 — Python 3.11.1 documentation
When the Python interpreter is interrupted by Ctrl-C (SIGINT) and the resulting KeyboardInterrupt exception is not caught, the Python process now exits via...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found