hydrogen
hydrogen copied to clipboard
Virtualenv 20: Jupyter Kernels not detected
Prerequisites
- [x] Have you checked the solutions in our troubleshooting guide for common problems ?
- [x] Have you checked that your issue isn't already filed ?
Description
When creating an environment using virtualenv >= 20, Hydrogen is unable to automatically pick up Kernels available in the environment. This used to work just fine with virtualenv < 20.
Steps to Reproduce
To reproduce this we need four environments:
oldvenv, created by system-virtualenv, with virtualenv<20 insidenewvenv, created by system-virtualenv, with virtualenv>=20 insidevenv16, created by virtualenv<20 from environment 1, with Jupyter insidevenv20, created by virtualenv>=20 from environment 2, with Jupyter inside
virtualenv oldvenv
oldvenv/bin/pip install "virtualenv < 20"
virtualenv newvenv
newvenv/bin/pip install "virtualenv >= 20"
oldvenv/bin/virtualenv --version
oldvenv/bin/virtualenv venv16
newvenv/bin/virtualenv --version
newvenv/bin/virtualenv venv20
venv16/bin/pip install jupyter
venv20/bin/pip install jupyter
source venv16/bin/activate
atom .
# run some Python script, Kernels are detected
deactivate
source venv20/bin/activate
atom .
# run some Python script, Kernels are not detected
Versions
OS version: Arch Linux latest
atom --version
Atom : 1.45.0
Electron: 4.2.12
Chrome : 69.0.3497.128
Node : 10.11.0
apm --version
apm 2.4.5
npm 6.14.4
node 13.13.0 x64
atom 1.45.0
python 3.8.2
git 2.26.1
Hydrogen version:
2.14.1
Plugins
Have you installed and activated any of the Hydrogen plugins below ?
- [ ] hydrogen-python
- [ ] Hydrogen Launcher
- [ ] Data Explorer
Logs
There is only findCodeBlock and CellManager content in the logs, they are unrelated to Kernel detection.
Expected behavior
I expect Hydrogen to pick up Kernels in environments created by both virtualenv<20 and virtualenv>=20.
I started looking into how venv16 and venv20 differ and I noticed that Virtualenv 20 creates python as a symlink to the system-wide python, and Virtualenv 16 doesn't.
ls -alh venv16/bin/python
# -rwxr-xr-x 1 nils nils 14K 16. Apr 10:13 venv16/bin/python*
ls -alh venv20/bin/python
# lrwxrwxrwx 1 nils nils 18 16. Apr 10:13 venv20/bin/python -> /usr/bin/python3.8*
If I create the virtualenv using the --copies flag, no such symlink is created but the executable is instead copied:
newvenv/bin/virtualenv --copies venv20copies
venv20copies/bin/pip install jupyter
source venv20copies/bin/activate
atom .
And Kernels are successfully detected.
So it seems the Hydrogen Kernel detector is unable to deal with symlinks?
As a workaround, you may create a virtualenv config file (see the last line of virtualenv --help for the location of that file) with the contents
[virtualenv]
copies = True