Search code examples
pythonjupyter-notebookanacondawolfram-mathematicawolfram-language

Problem with configuring WolframLanguageForJupyter


I'm trying to configure WolframLanguageForJupyter. This project can be found at: https://github.com/WolframResearch/WolframLanguageForJupyter

I tried both the methods mentioned in that page, i.e., using a paclet and using the wls file in the git repository. I get the following error,

In[5]:= ConfigureJupyter["Add"]
Traceback (most recent call last):
  File "C:\Anaconda3\Scripts\jupyter-kernelspec-script.py", line 5, in <module>
    from jupyter_client.kernelspecapp import KernelSpecApp
  File "C:\Anaconda3\lib\site-packages\jupyter_client\__init__.py", line 4, in <module>
    from .connect import *
  File "C:\Anaconda3\lib\site-packages\jupyter_client\connect.py", line 21, in <module>
    import zmq
  File "C:\Anaconda3\lib\site-packages\zmq\__init__.py", line 55, in <module>
    from zmq import backend
  File "C:\Anaconda3\lib\site-packages\zmq\backend\__init__.py", line 40, in <module>
    reraise(*exc_info)
  File "C:\Anaconda3\lib\site-packages\zmq\utils\sixcerpt.py", line 34, in reraise
    raise value
  File "C:\Anaconda3\lib\site-packages\zmq\backend\__init__.py", line 27, in <module>
    _ns = select_backend(first)
  File "C:\Anaconda3\lib\site-packages\zmq\backend\select.py", line 28, in select_backend
    mod = __import__(name, fromlist=public_api)
  File "C:\Anaconda3\lib\site-packages\zmq\backend\cython\__init__.py", line 6, in <module>
    from . import (constants, error, message, context,
ImportError: DLL load failed while importing error: The specified module could not be found.


ConfigureJupyter::notadded: 
   An error has occurred. The desired Wolfram Engine is not in "jupyter kernelspec list." See
    WolframLanguageForJupyter`Errors`$ConfigureError for the message that Jupyter returned when
    attempting to add the Wolfram Engine.

I'm not sure what exactly the problem is. Any help would be appreciated.


Solution

  • For anyone who is trying to configure WolframLanguageForJupyter for an Anaconda installation (Windows).

    Git repo of WolframLanguageForJupyter.

    The paclet that automatically configures Wolfram Engine for Jupyter notebook is simply incompatible with Anaconda installations. One fix to this problem is to not use Anaconda and use pip instead. But if you would like to keep your Anaconda installation, then try the following steps.

    1. Make sure that your Anaconda installation path is added to the environment variables. You should basically have "$anaconda-installation$" and "$anaconda-installation$\Scripts" in your PATH environment variable.
    2. Now create a virtual environment. To do this, run conda create -n environment-name python=x.x anaconda in cmd/powershell/anaconda prompt. This should create a virtual environment called environment-name. To switch into the virtual environment, run conda activate environment-name and to deactivate the virtual environment, run conda deactivate. To list all the environments, run conda info -e.

    Note: You might have to initialise the shell before switching to an environment if you are using cmd/powershell. To do this, simply run conda init cmd.exe or conda init powershell. Also, to delete your virtual environment, run conda remove -n environment-name -all.

    1. Now download the zip of the repo and extract it. Run a powershell window from the root of the folder. Now activate your virtual environment and run .\configure-jupyter.wls add. This should configure WolframLanguageForJupyter. To check if everything has been configured correctly, run jupyter kernelspec list. This should list Wolfram Engine, if successfully configured.