gap-packages / JupyterKernel

Native Jupyter kernel for GAP
https://gap-packages.github.io/JupyterKernel/
BSD 3-Clause "New" or "Revised" License
19 stars 12 forks source link

Trouble with Installation #76

Closed BNasmith closed 5 years ago

BNasmith commented 5 years ago

Hello, I'm having trouble getting the GAP kernel for Jupyter to work. I have Python 3.6 installed on my Windows computer and GAP 4.9.3. I used the pip install --user notebook command in Bash to ensure that my Jupyter installation was up to date (I used it with Python 3 already) and I navigated to the C:\gap-4.9.3\pkg\JupyterKernel-0.999999 directory and ran the python setup.py install --user command.

Now, when I open Jupyter notebook I am able to select a new "GAP 4" notebook, as expected. But when I do create it, I get a "Kernel Error", with the following message. I'm not quite sure what to do next to make this work. Any help would be appreciated.

Traceback (most recent call last):
  File "c:\users\benna\appdata\local\programs\python\python36\lib\site-packages\tornado\web.py", line 1511, in _execute
    result = yield result
  File "c:\users\benna\appdata\local\programs\python\python36\lib\site-packages\tornado\gen.py", line 1055, in run
    value = future.result()
  File "c:\users\benna\appdata\local\programs\python\python36\lib\site-packages\tornado\concurrent.py", line 238, in result
    raise_exc_info(self._exc_info)
  File "<string>", line 4, in raise_exc_info
  File "c:\users\benna\appdata\local\programs\python\python36\lib\site-packages\tornado\gen.py", line 1063, in run
    yielded = self.gen.throw(*exc_info)
  File "c:\users\benna\appdata\local\programs\python\python36\lib\site-packages\notebook\services\sessions\handlers.py", line 73, in post
    type=mtype))
  File "c:\users\benna\appdata\local\programs\python\python36\lib\site-packages\tornado\gen.py", line 1055, in run
    value = future.result()
  File "c:\users\benna\appdata\local\programs\python\python36\lib\site-packages\tornado\concurrent.py", line 238, in result
    raise_exc_info(self._exc_info)
  File "<string>", line 4, in raise_exc_info
  File "c:\users\benna\appdata\local\programs\python\python36\lib\site-packages\tornado\gen.py", line 1063, in run
    yielded = self.gen.throw(*exc_info)
  File "c:\users\benna\appdata\local\programs\python\python36\lib\site-packages\notebook\services\sessions\sessionmanager.py", line 79, in create_session
    kernel_id = yield self.start_kernel_for_session(session_id, path, name, type, kernel_name)
  File "c:\users\benna\appdata\local\programs\python\python36\lib\site-packages\tornado\gen.py", line 1055, in run
    value = future.result()
  File "c:\users\benna\appdata\local\programs\python\python36\lib\site-packages\tornado\concurrent.py", line 238, in result
    raise_exc_info(self._exc_info)
  File "<string>", line 4, in raise_exc_info
  File "c:\users\benna\appdata\local\programs\python\python36\lib\site-packages\tornado\gen.py", line 1063, in run
    yielded = self.gen.throw(*exc_info)
  File "c:\users\benna\appdata\local\programs\python\python36\lib\site-packages\notebook\services\sessions\sessionmanager.py", line 92, in start_kernel_for_session
    self.kernel_manager.start_kernel(path=kernel_path, kernel_name=kernel_name)
  File "c:\users\benna\appdata\local\programs\python\python36\lib\site-packages\tornado\gen.py", line 1055, in run
    value = future.result()
  File "c:\users\benna\appdata\local\programs\python\python36\lib\site-packages\tornado\concurrent.py", line 238, in result
    raise_exc_info(self._exc_info)
  File "<string>", line 4, in raise_exc_info
  File "c:\users\benna\appdata\local\programs\python\python36\lib\site-packages\tornado\gen.py", line 307, in wrapper
    yielded = next(result)
  File "c:\users\benna\appdata\local\programs\python\python36\lib\site-packages\notebook\services\kernels\kernelmanager.py", line 141, in start_kernel
    super(MappingKernelManager, self).start_kernel(**kwargs)
  File "c:\users\benna\appdata\local\programs\python\python36\lib\site-packages\jupyter_client\multikernelmanager.py", line 110, in start_kernel
    km.start_kernel(**kwargs)
  File "c:\users\benna\appdata\local\programs\python\python36\lib\site-packages\jupyter_client\manager.py", line 257, in start_kernel
    **kw)
  File "c:\users\benna\appdata\local\programs\python\python36\lib\site-packages\jupyter_client\manager.py", line 203, in _launch_kernel
    return launch_kernel(kernel_cmd, **kw)
  File "c:\users\benna\appdata\local\programs\python\python36\lib\site-packages\jupyter_client\launcher.py", line 128, in launch_kernel
    proc = Popen(cmd, **kwargs)
  File "c:\users\benna\appdata\local\programs\python\python36\lib\subprocess.py", line 709, in __init__
    restore_signals, start_new_session)
  File "c:\users\benna\appdata\local\programs\python\python36\lib\subprocess.py", line 997, in _execute_child
    startupinfo)
FileNotFoundError: [WinError 2] The system cannot find the file specified
olexandr-konovalov commented 5 years ago

Thanks for reporting this. How did you install GAP - from .exe installer, or using Unix subsystem in Windows 10?

BNasmith commented 5 years ago

I installed GAP using the Windows .exe installer. I'm having the same problem with GAP 4.9.3 on one Windows 10 machine and GAP 4.9.2 on a Windows 7 machine.

olexandr-konovalov commented 5 years ago

Sorry for not replying earlier @BNasmith. Did you manage to find some workaround in the meantime?

Unfortunately, the package is not yet usable on Windows if you install from .exe installer because that one does not provide usable ZeroMQInterface package. For now, on Windows I would suggest to try the Unix subsystem (if on Windows 10), or a Linux virtual machine, or Docker.

BNasmith commented 5 years ago

Hello again and thanks. I'm currently using GAP-4.10.0 linux version using the Windows Subsystem for Linux on Windows 10. I tried to follow the steps to install JupyterKernel (1.0 this time). I'm able to open the browser notebook, but the Kernel still fails to start property. I tried running autogen.sh in the ZeroMQInterface package (I didn't see any instructions in the documentation about how to set it up). Not sure what to try next. Here's my kernel error code:


  File "/home/bnasmith/.local/lib/python2.7/site-packages/tornado/web.py", line 1592, in _execute
    result = yield result
  File "/home/bnasmith/.local/lib/python2.7/site-packages/tornado/gen.py", line 1133, in run
    value = future.result()
  File "/home/bnasmith/.local/lib/python2.7/site-packages/tornado/concurrent.py", line 261, in result
    raise_exc_info(self._exc_info)
  File "/home/bnasmith/.local/lib/python2.7/site-packages/tornado/gen.py", line 1141, in run
    yielded = self.gen.throw(*exc_info)
  File "/home/bnasmith/.local/lib/python2.7/site-packages/notebook/services/sessions/handlers.py", line 73, in post
    type=mtype))
  File "/home/bnasmith/.local/lib/python2.7/site-packages/tornado/gen.py", line 1133, in run
    value = future.result()
  File "/home/bnasmith/.local/lib/python2.7/site-packages/tornado/concurrent.py", line 261, in result
    raise_exc_info(self._exc_info)
  File "/home/bnasmith/.local/lib/python2.7/site-packages/tornado/gen.py", line 1141, in run
    yielded = self.gen.throw(*exc_info)
  File "/home/bnasmith/.local/lib/python2.7/site-packages/notebook/services/sessions/sessionmanager.py", line 79, in create_session
    kernel_id = yield self.start_kernel_for_session(session_id, path, name, type, kernel_name)
  File "/home/bnasmith/.local/lib/python2.7/site-packages/tornado/gen.py", line 1133, in run
    value = future.result()
  File "/home/bnasmith/.local/lib/python2.7/site-packages/tornado/concurrent.py", line 261, in result
    raise_exc_info(self._exc_info)
  File "/home/bnasmith/.local/lib/python2.7/site-packages/tornado/gen.py", line 1141, in run
    yielded = self.gen.throw(*exc_info)
  File "/home/bnasmith/.local/lib/python2.7/site-packages/notebook/services/sessions/sessionmanager.py", line 92, in start_kernel_for_session
    self.kernel_manager.start_kernel(path=kernel_path, kernel_name=kernel_name)
  File "/home/bnasmith/.local/lib/python2.7/site-packages/tornado/gen.py", line 1133, in run
    value = future.result()
  File "/home/bnasmith/.local/lib/python2.7/site-packages/tornado/concurrent.py", line 261, in result
    raise_exc_info(self._exc_info)
  File "/home/bnasmith/.local/lib/python2.7/site-packages/tornado/gen.py", line 326, in wrapper
    yielded = next(result)
  File "/home/bnasmith/.local/lib/python2.7/site-packages/notebook/services/kernels/kernelmanager.py", line 160, in start_kernel
    super(MappingKernelManager, self).start_kernel(**kwargs)
  File "/home/bnasmith/.local/lib/python2.7/site-packages/jupyter_client/multikernelmanager.py", line 110, in start_kernel
    km.start_kernel(**kwargs)
  File "/home/bnasmith/.local/lib/python2.7/site-packages/jupyter_client/manager.py", line 259, in start_kernel
    **kw)
  File "/home/bnasmith/.local/lib/python2.7/site-packages/jupyter_client/manager.py", line 204, in _launch_kernel
    return launch_kernel(kernel_cmd, **kw)
  File "/home/bnasmith/.local/lib/python2.7/site-packages/jupyter_client/launcher.py", line 138, in launch_kernel
    proc = Popen(cmd, **kwargs)
  File "/usr/lib/python2.7/subprocess.py", line 394, in __init__
    errread, errwrite)
  File "/usr/lib/python2.7/subprocess.py", line 1047, in _execute_child
    raise child_exception
OSError: [Errno 2] No such file or directory```
BNasmith commented 5 years ago

A small amount of progress: I realized I needed to add a link to jupyter-notebook-kernel to /user/local/bin. Now the kernel seems to be stuck in a loop on this problem:

GAP Jupyter Kernel Starting using gap
[I 20:42:04.473 NotebookApp] Kernel started: 6423d1e8-85be-472c-9389-0498e97951db
fail
Error, Variable: 'JUPYTER_KernelStart_GAP' must have a value
not in any function at *stdin*:2
[I 20:42:34.349 NotebookApp] KernelRestarter: restarting kernel (1/5), keep random ports
GAP Jupyter Kernel Starting using gap
fail
Error, Variable: 'JUPYTER_KernelStart_GAP' must have a value
not in any function at *stdin*:2
olexandr-konovalov commented 5 years ago

@BNasmith could you please check what happens if you start GAP in the terminal and call

LoadPackage("JupyterKernel");
BNasmith commented 5 years ago

Sure, here's what I get:

 ┌───────┐   GAP 4.10.0 of 01-Nov-2018
 │  GAP  │   https://www.gap-system.org
 └───────┘   Architecture: x86_64-pc-linux-gnu-default64
 Configuration:  gmp 6.1.2, readline
 Loading the library and packages ...
 Packages:   AClib 1.3.1, Alnuth 3.1.0, AtlasRep 1.5.1,
             AutoDoc 2018.09.20, AutPGrp 1.10, CRISP 1.4.4,
             Cryst 4.1.18, CrystCat 1.1.8, CTblLib 1.2.2, FactInt 1.6.2,
             FGA 1.4.0, GAPDoc 1.6.2, IRREDSOL 1.4, LAGUNA 3.9.0,
             Polenta 1.3.8, Polycyclic 2.14, PrimGrp 3.3.2,
             RadiRoot 2.8, ResClasses 4.7.1, SmallGrp 1.3, Sophus 1.24,
             SpinSym 1.5, TomLib 1.2.7, TransGrp 2.0.4, utils 0.59
 Try '??help' for help. See also '?copyright', '?cite' and '?authors'
gap> LoadPackage("JupyterKernel");
#I  JupyterKernel package is not available. To see further details, enter
#I  SetInfoLevel(InfoPackageLoading,4); and try to load the package again.fail
gap> SetInfoLevel(InfoPackageLoading,4);
gap> LoadPackage("JupyterKernel");
#I  JupyterKernel: entering LoadPackage
#I  JupyterKernel: PackageAvailabilityInfo for version 1.0
#I  JupyterKernel: PackageAvailabilityInfo: the AvailabilityTest function returned 'true'
#I  JupyterKernel: PackageAvailabilityInfo: check needed packages
#I                 GAPDoc (>= 1.6.1)
#I                 io (>= 4.5.4)
#I                 json (>= 2.0.0)
#I                 uuid (>= 0.6)
#I                 ZeroMQInterface (>= 0.10)
#I                 crypting (>= 0.9)
#I  IO: PackageAvailabilityInfo for version 4.5.4
#I      (required: >= 4.5.4)
#I  IO: PackageAvailabilityInfo: the AvailabilityTest function returned fail
#I  IO: PackageAvailabilityInfo: no installed version fits
#I  JupyterKernel: PackageAvailabilityInfo: dependency 'io' is not satisfied
#I  JupyterKernel: PackageAvailabilityInfo: check of needed packages done
#I  JupyterKernel: PackageAvailabilityInfo: no installed version fits
#I  JupyterKernel: return from LoadPackage, package is not available
fail
olexandr-konovalov commented 5 years ago

As https://www.gap-system.org/Releases/ says, after building GAP you also need to do

cd pkg ../bin/BuildPackages.sh

Please do that if you haven't tried yet. Also, you may need to call apt-get install libzmq3-dev to be able to build the ZeroMQInterface package - do this before building packages, if you haven't done this yet.

At the end the BuildPackages.sh script will also produce a file with the list of packages it failed to build. I will be interested in the content of that file. Then, try to call LoadPackage("JupyterKernel"); again and see if it loads or another package causes a problem.

BNasmith commented 5 years ago

Thanks again. I followed these steps and now LoadPackage("JupyterKernel"); return true in GAP. Here's the log of failed to build packages:

Packages which failed to build are in ./log/fail.log
bnasmith@DESKTOP-P5CR1P3:/mnt/c/gap-4.10.0/pkg$ cat ./log/fail.log
Thu Dec 20 09:12:54 STD 2018
anupq-3.2
curlInterface-2.1.1
guava-3.14
Thu Dec 20 09:29:44 STD 2018
anupq-3.2
curlInterface-2.1.1
NormalizInterface-1.0.2
xgap-4.28

That said, it seems to be working now. I can type jupyter notebook at the command prompt in the Windows Subsystem for Linux and create a notebook running GAP 4. Thanks very much. It seems that the problem was just me learning how to use the linux version of GAP properly!

olexandr-konovalov commented 5 years ago

Thanks, this is great! Also, a good list of packages which compiled successfully. I would be interested what happened with anupq - if you will need it and will need some help, you can submit an issue to https://github.com/gap-packages/anupq/. For curlInterface, use apt-get install libcurl4-openssl-dev and then rebuild the package with ./configure; make. NormalizInterface requires Normaliz to be installed, and XGAP requires the X Window system - don't know if this will work on Windows 10.

Good to learn that it works when Jupyter is started from the Windows command prompt! This will be certainly useful for https://github.com/gap-packages/JupyterKernel/issues/45. How did you install Python and Jupyter - did you get it from Anaconda, from Python website, or it is installed in Linux subsystem?

BNasmith commented 5 years ago

Actually, I don't have it working from the Windows command prompt. Rather, I am using the Windows Subsystem for Linux (WSL), on which I installed GAP 4.10.0 for Linux. I also installed Jupyter Notebook on WSL and I think WSL recognized my prior Windows Python installation. So I'm running Jupyter Notebook from WSL and simply copy-pasting the link it provides to a browser (WSL won't open a browser automatically). Then things seem to work just fine.

After I ran into trouble with GAPDOC using Windows a while ago I decided to try and use GAP with Linux on WSL whenever possible. I'm just getting starting with it and so far I'm pretty happy with that approach. Thanks again,

olexandr-konovalov commented 5 years ago

Nice - thanks for clarifications! Also, you mentioned two Python installations above, with 3.6 and 2.7 - seems like the former is in Windows, the latter - in WSL.

Since it works, I will close this issue now - please open a new one, if there will be any questions!