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.

Jupyter notebook doesn't respect python.pythonPath

See original GitHub issue

Environment data

  • VS Code version: 1.44.0-insider, 073a24de05773f2261f89172987002dc0ae2f1cd, x64
  • Extension version (available under the Extensions sidebar): 2020.3.69010
  • OS and version: Linux 5.4.27, NixOS, x86_64 GNU/Linux
  • Python version (& distribution if applicable, e.g. Anaconda): 3.7.6, Nix
  • Type of virtual environment used (N/A | venv | virtualenv | conda | …): direnv
  • Relevant/affected Python packages and their versions: …
  • Relevant/affected Python-related VS Code extensions and their versions: …
  • Jedi or Language Server? (i.e. what is "python.jediEnabled" set to; more info #3977): Language Server
  • Value of the python.languageServer setting: Microsoft

Expected behaviour

Defaults to python.pythonPath

Actual behaviour

Not sure, it either uses the system configuration of python.pythonPath or defaults to the whatever the python in $PATH is.

Steps to reproduce:

settings.json

{
  "python.pythonPath": ".direnv/python/bin/python"
}
➜ l .direnv
total 1.0K
drwxr-xr-x  2  0 Mar 24 13:23 .
drwxr-xr-x 11  0 Mar 24 13:15 ..
lrwxrwxrwx  1 61 Mar 24 13:23 python -> /nix/store/2qkmajsj18pl8cz5hjjyslg10mblfmbd-python3-3.7.6-env
lrwxrwxrwx  1 61 Mar 24 13:23 python-3.7.6 -> /nix/store/2qkmajsj18pl8cz5hjjyslg10mblfmbd-python3-3.7.6-env

➜ readlink -f .direnv/python/bin/python
/nix/store/2qkmajsj18pl8cz5hjjyslg10mblfmbd-python3-3.7.6-env/bin/python

Nix and direnv files can be provided if needed.

Logs

Output for Python in the Output panel (ViewOutput, change the drop-down the upper-right of the Output panel to Python)

...
> /nix/store/xb1mp0f16lv23rwhfdc1665v5r20jfmm-python3-3.7.6/bin/python3 -c "import notebook"
> /nix/store/xb1mp0f16lv23rwhfdc1665v5r20jfmm-python3-3.7.6/bin/python3 -c "import notebook"
> /nix/store/xb1mp0f16lv23rwhfdc1665v5r20jfmm-python3-3.7.6/bin/python3 -c "import jupyter"
> /nix/store/xb1mp0f16lv23rwhfdc1665v5r20jfmm-python3-3.7.6/bin/python3 -c "import jupyter"
> /nix/store/xb1mp0f16lv23rwhfdc1665v5r20jfmm-python3-3.7.6/bin/python3 -c "import notebook"
> /nix/store/xb1mp0f16lv23rwhfdc1665v5r20jfmm-python3-3.7.6/bin/python3 -c "import notebook"
> /nix/store/xb1mp0f16lv23rwhfdc1665v5r20jfmm-python3-3.7.6/bin/python3 -c "import jupyter"
> /nix/store/xb1mp0f16lv23rwhfdc1665v5r20jfmm-python3-3.7.6/bin/python3 -c "import jupyter"
> /nix/store/xb1mp0f16lv23rwhfdc1665v5r20jfmm-python3-3.7.6/bin/python3 -c "import notebook"
> /nix/store/xb1mp0f16lv23rwhfdc1665v5r20jfmm-python3-3.7.6/bin/python3 -c "import notebook"
...

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:12 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
DonJayamannecommented, Mar 26, 2021

@GuillaumeDesforges If its ok with you, i’m going to create an issue in another repo to discuss the issue with you further. I believe what you are experiencing is slightly different.

I’ve filed the issue here https://github.com/microsoft/vscode-jupyter/issues/5335

1reaction
ericsnowcurrentlycommented, Apr 1, 2020

@eadwu, sorry this is taking so long. We’ll take a look as soon as possible.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to make Jupyter notebook use PYTHONPATH in system ...
In pure Python, it prepends my system environment variable PYTHONPATH to sys.path but Jupyter notebook doesn't, so I can't import my own module....
Read more >
How can I pass environment variabel PYTHONPATH to ...
I have implemented or better called jupyter notebook in a terminal session, no problem at all. The object is to share import (environment)...
Read more >
jupyterlab not honouring PYTHONPATH env var
Dear all, version 0.32.1 of JupyterLab does not seem to honour the `PYTHONPATH` env var if it is set upon launch of the...
Read more >
Jupyter notebook not installing - Python - Codecademy Forums
Your python command is already on your PATH in this case so you can use it directly. It (python) has its own path...
Read more >
Jupyter Documentation - Read the Docs
This information explains how to install the Jupyter Notebook and the IPython kernel. Prerequisite: Python. While Jupyter runs code in many programming ...
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