Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Virtualenv 20: Jupyter Kernels not detected #1911

Open
2 of 5 tasks
nils-werner opened this issue Apr 16, 2020 · 1 comment
Open
2 of 5 tasks

Virtualenv 20: Jupyter Kernels not detected #1911

nils-werner opened this issue Apr 16, 2020 · 1 comment
Labels
bug 🐛 For unexpected issues

Comments

@nils-werner
Copy link

nils-werner commented Apr 16, 2020

Prerequisites

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:

  1. oldvenv, created by system-virtualenv, with virtualenv<20 inside
  2. newvenv, created by system-virtualenv, with virtualenv>=20 inside
  3. venv16, created by virtualenv<20 from environment 1, with Jupyter inside
  4. venv20, 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.

@nils-werner nils-werner added the bug 🐛 For unexpected issues label Apr 16, 2020
@nils-werner
Copy link
Author

nils-werner commented Apr 16, 2020

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 For unexpected issues
Projects
None yet
Development

No branches or pull requests

1 participant