ipython kernel doesn't recognize user def modules of .env
See original GitHub issueEnvironment data
VS Code version: 1.37.1 Extension version (available under the Extensions sidebar): 2019.8.30787 OS and version: windows 10 Python version (& distribution if applicable, e.g. Anaconda): python 3.7.1 Type of virtual environment used (N/A | venv | virtualenv | conda | …): venv Relevant/affected Python packages and their versions: - Jedi or Language Server? (i.e. what is “python.jediEnabled” set to; more info microsoft/vscode-python#3977): -
Expected behavior
with .env file that points to some subdir that is the package, both regular run and interactive run of some script should recognize the modules.
Actual behavior
ipython can’t recognize non workspace PYTHONPATH/ sys.path.append(“…”)
Steps to reproduce:
workdir
+.env (in which the python path of src is appended: PYTHONPATH=./src;${PYTHONPATH})
+src
+-foo
+--__init__.py
+--foo.py
+-bar
+--bar.py
in bar.py call “import foo.foo as foo” when running interactively. one can also try to sys.path.append(“…”) but this also doesnt work in this case… This action works in Binder and in pycharm (using “mark as package dir” + “mark as source dir” of src).
probably the most convenient solution is to implement “mark as package dir” + “mark as source dir” like pycharm which will work for regular and ipython runs.
a more un-IDE solution is just to enable .env to work with ipython.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:2
- Comments:9 (7 by maintainers)
Top GitHub Comments
This bug is currently in the ‘Nice to have bug fixes for feb 2020’, so it’s a maybe for fixing now. More likely for the March release.
I may be wrong, but I believe the .env file is supported by the python extension, but not be VS code itself. VS code is responsible for the integrated terminal, so the integrated terminal doesn’t support .env files.
I also noticed that the interactive is launched always inside the directory of the first project of a workspace.
Is there a mini document on how to hack iPython’s extension?