Some notes on using IJulia (and nbextensions) as a Python noob

Back in 2013, I was looking for an open-source alternative to Matlab (my weapon of choice for the 20+ years prior). The obvious candidates were:

  • Python
  • R
  • Octave

I quickly ruled out Octave and didn’t see myself using R so was about to go with Python, when I found this new kid on the block, Julia lang, and there was no looking back :heart::blush:

Since then, I’ve actively tried to avoid Python (my brain can only handle so much), but occassionally I need something Python related. I know it is mostly because I’m clueless about Python, but every time I wade in those waters, it feels like hell on Earth :sweat_smile::fire:

Every few months, I feel I learn / struggle enough to get what I need done, but promptly forget and have to repeat the same misery every few months.

These notes are mainly for myself, but might help anyone else in a similar situation :slight_smile:

Package Manager

I guess Python has a few different package managers, but the ones you (I) probably need to be aware of are pip and conda. These are typically run from the command line, but after installing IJulia, those commands are not available from the Windows command line.

Do not be fooled into installing a new Python just so you can access these package managers (like I did!).

Instead, when you install IJulia, it also installs a dependency: Conda.jl.

If you want to install any Jupyter extensions, you can use Conda for this from Julia. No need to wade into Python waters :pray:

Registries

Realizing I could use Conda from Julia was a huge relief (I could uninstall the Python I erroneously installed earlier trying to get pip to work), but that was only part of the picture. Aparently, Python has something called “channels”, which seem to me very similar to registries in Julia.

Conda has some registries, err… channels, preconfigured, but it didn’t have the one I needed, which was conda-forge.

The solution, in traditional Julia form, was easy peasy:

julia> Conda.add_channel("conda-forge")

From there, I could install the notebook extensions

julia> Conda.add("jupyter_contrib_nbextensions")

So far so good!

Enabling the Extensions

If anyone has a better way to do this from Julia, please let me know, but you may need to access the jupyter command. I don’t know how to access this from Julia, so I had to leave the comfort of Julia and go back to the command line.

However, as noted in the IJulia README:

Note that if you installed jupyter via automated Miniconda installer in Pkg.add , above, then jupyter may not be in your PATH ; type import Conda; Conda.SCRIPTDIR in Julia to find out where Conda installed jupyter .

I admit, I almost installed Python AGAIN to access this command until I found that note in the README :pray:

After finding the correct path and adding it to my PATH environment variable, I was able to access jupyter from the command line.

However, to enable to extensions, it turns out I didn’t even need the jupyter command. Back in the comfort of Julia, you can run:

julia> Conda.add("jupyter_nbextensions_configurator")

Voila!

Now, if you shut down Jupyter completely and restart IJulia, you should have an “nbextensions config” option under the Edit menu. Alternatively, you can just navigate directly to

http://localhost:8888/nbextensions

I hope this helps someone, but it will surely help a future me :slight_smile:

7 Likes