Is there a way to run scala code in the ipython notebook? - scala

I know there is the script magics in the ipython notebook for running code in other languages. See for example http://nbviewer.ipython.org/url/github.com/ipython/ipython/raw/master/examples/notebooks/Script%20Magics.ipynb.
And I know you can run Scala in script mode. See, for example http://www.scala-lang.org/old/node/166.
But I couldn't figure out if there was a way to get the ipython notebook to run scala code.

Second google answer for "Ipython scala" search yield IScala notebook announce.

OP has asked about running scala code in the ipython notebook, not if there's an ipython equivalent for scala. he is aware he can run it with magics as any other script.
a better answer, though still not what OP has asked, is a project for running scala in the similar fashion of notebooks in a web page https://github.com/Bridgewater/scala-notebook

Related

How does Jupyter find modules?

I'm trying to troubleshoot an issue where my Jupyter Notebook can't find an installed module, and I'm surprised that I can't find this basic information anywhere in the documentation. How do I specify where any given instance of Jupyter Notebook should look for modules?
A possibly related question: When I use jupyter --path, I see a listing of directories under the "data" heading. Is this where Jupyter looks for modules, and if so, what file do I edit to change it?
Edit I'm starting to understand, and I think I asked the wrong question. Jupyter loads a Python interpreter, and the interpreter is what deals with modules. How a Python interpreter finds modules is well-covered territory, but I still don't understand the first part. So, I should have asked, "How does Jupyter determine which Python executable to use?"

How can I use scala with jupyter notebook?

I want to use scala with jupyter notebook, the same way we use IJulia.
One solution that I found was by cloning https://github.com/alexarchambault/jupyter-scala
Is there any other way out ?
The Jupyter documentation links to IPython kernels for other languages
It appears to be a comprehensive list.

How to work with Scala in vagrant box spark installation?

I installed spark using instructions provided at https://courses.edx.org/courses/BerkeleyX/CS100.1x/1T2015/courseware/d1f293d0cb53466dbb5c0cd81f55b45b/920d3370060540c8b21d56f05c64bdda/
This lets me run jupyter ipython notebook which provides a pyspark interface on localhost browser. But I wanted to learn more about Scala.
What could be the best way to run Scala using this vagrant based installation. Is there a way that I can run some sort of IDE with this vagrant config. The best would be if I am able to use some notebook like interface to Scala.
Thanks
You can run Scala from jupyter ipython notebook interface. Select New-Terminal. Then, type this command "spark-shell". Scala API window will open.
I hope that will help you

convert ipython notebook to python without ipython

Is there an easy way to convert an ipython notebook to plain python without using ipython itself (i.e. not using ipython nbconvert --to=python ...)?
Background: I want to test if there is a syntax error in various ipython notebooks using travis-ci. However, installing ipython from source takes too long and the ubuntu packages are outdated.
I wrote a simple script that does the conversion. It's probably not fool-proof but works for me. I'd still be happy to hear about a better solution.
Link to script: https://gist.github.com/hannorein/8423ad75547f37bba228

Display of music21, musicXML PNG objects using iPython Notebook/Enthought Canopy

I am experimenting with the music21 library, in preparation for a Machine Learning project that involves genre classification and categorization. I and following some tutorials available here. I am using MuseScore as my MusicXML program, and I am trying to run the whole thing from iPython.
Although I can run the some of the turtorials from the terminal, some elements don't seem to run well from inside iPython. For example:
In [3]: sBach.show()
Out[3]: <music21.ipython21.objects.IPythonPNGObject at 0x10da0aa10>
The line above shows that the PNG object is created, but not displayed. The expected output for 3 above is the following:
Experimenting with the following iPython command, I get a placeholder for an image, but not image.
In [6]: %load_ext music21.ipython21.ipExtension
In [7]: sBach.show()
I can't find any problem with my MusicXMLPath. This tutorial refers to the use of musc21 with Anaconda, but all my developments is done with Enthought, so I prefer not to run another virtual environment to use music21 with iPython.
Is there any way to run music21 in an Enthought/iPython notebook?
I have been grappling with this issue myself. ... Have you set your musicxmlPath in music21? If you have not, it's done via environment.set(key, value). You can query for available keys with environment.keys(). I hope this isn't too simple an answer, but it cleared up the problem for me.
This should be in the iPython music21 documentation somewhere, my apologies: iPython in music21 requires Lilypond to be installed for images to be generated within the notebook itself. There hasn't been (and won't be until MuseScore 2.0 is released) a way using MusicXML to generate PNG images of scores directly.
Edit: 2015 July; music21 2.0 w/ MuseScore 2 will generate the PNG images with MuseScore if it is installed and fallback to Lilypond if it is not installed.
If not yet tried, some steps to isolate the cause of the problem:
1) Update to the latest Canopy (Edit: currently 1.4.1) (might help this, will help generally, won't hurt).
2) Change the Pylab backend in Canopy's IPython shell to "Inline (SVG)", via Preferences / Python. (The default Qt backend in that shell conflicts with music21's use of the tkinter library.)
3) Test your script in that shell rather than in the notebook.
4) Ensure that Canopy User Python is your default Python in a Terminal window, as described here.
5) Test your scripts inside of plain ipython terminal (from Terminal, type ipython).
6) Test in ipython terminal in pylab mode (ipython qtconsole --pylab=inline).
7) Test your scripts inside of ipython notebook running in a regular browser (from Terminal, type ipython notebook, and/or ipython notebook --pylab=inline).
Had similar issues before. It's the same problem when people try to use plot function in ipython/jupyter notebook. You need to call
%matplotlib inline
For me the issue was solved by uninstalling the snap version of musescore and installing it from ppa:mscore-ubuntu/mscore3-stable via https://launchpad.net/~mscore-ubuntu/+archive/ubuntu/mscore3-stable