n-riesco / ijavascript

IJavascript is a javascript kernel for the Jupyter notebook
Other
2.18k stars 187 forks source link

How to install IJavascript in anaconda 3 #182

Closed iduchy closed 5 years ago

iduchy commented 5 years ago

'npm install -g ijavascript' within conda with python env 3.7 failed:

gyp ERR! stack Error: Command failed: ./bin/python -c import sys; print "%s.%s.%s" % sys.version_info[:3]; gyp ERR! stack File "", line 1 gyp ERR! stack import sys; print "%s.%s.%s" % sys.version_info[:3]; gyp ERR! stack ^ gyp ERR! stack SyntaxError: invalid syntax

works with python env 2.7

n-riesco commented 5 years ago

See #184 for more details on this issue.

Since python v2.7 is only required to build IJavascript's binaries (when the prebuilt binaries aren't available), you should be able to install IJavascript from env 2.7 and use the kernel from any other env.

If you used conda to install Node.js, you may need to install the IJavascript kernelspec using full paths, like this:

$ ijsinstall --spec-path=full
n-riesco commented 5 years ago

Closing in favour of #184

iduchy commented 5 years ago

I found the following problem with a hack like working solution:

n-riesco commented 5 years ago

@iduchy I'd need to see the commands you've run and the output you get (and to know the OS you're using).

If I understood correctly, you want to install IJavascript on a py37 conda env (so that you can install and use the latest versions of JupyterLab and Node).

I believe this is possible. The general idea is:

  1. activate the py37 env
  2. configure npm to use python2: npm config set python python2
  3. install IJavascript: npm install -g ijavascript
  4. install IJavascript kernelspec: ijsinstall --spec-path=full
iduchy commented 5 years ago

Yes, you understand correctly, but your idea does not work because of conda environment. They say in docs "If you want to use a different version of Python, for example Python 3.5, simply create a new environment and specify the version of Python that you want."

n-riesco commented 5 years ago

@iduchy did you try?

Linux and MAC come with their own Python 2 (and in those OSes, you wouldn't need a conda install to run python2)

iduchy commented 5 years ago

Thanks, i did not expect conda can see a python installed outside an environment (in /usr/bin)

BeyersNel commented 5 years ago

I believe this is possible. The general idea is:

1. activate the py37 env

2. configure npm to use python2: `npm config set python python2`

3. install IJavascript: `npm install -g ijavascript`

4. install IJavascript kernelspec: `ijsinstall --spec-path=full`

This did not resolve the problem for me, instead creating a Python2.7 environment with conda and installing from there worked fine.

shytikov commented 5 years ago

Could it be solved by updating zeromq to version 5? The way I have wrote in #201?

It seems to be roughly 20 issues in this repository on the same topic — and the first one is 2017... It should be possible to resolve them gracefully, without installing second python just for building JS shell.

n-riesco commented 5 years ago

@shytikov I've just released IJavascript@5.2 that uses jp-kernel@2 and the new prebuilt binaries for zeromq@5. This should make life easier for users of Anoconda 3 (at least, for the time being).

shytikov commented 5 years ago

@n-riesco everything worked smoothly for me now. And I have pretty strange setup:

But anyhow:

image

I believe that solves #181 more or less too.