To take a certain Online Machine Learning Course, [Octave](http: http: //www.coursera.org/learn/machine-learning "Machine Learning --Stanford University | Coursera") //www.gnu.org/software/octave/ "GNU Octave") has been installed.
So, I searched for the Octave kernel in Jupyter and installed it. I was a little addicted to it, so I recorded it for information sharing.
I was checking the operation and was addicted to handling Japanese, so I added and corrected the article.
[^ 4]: The main Python is 2.7.9, and 3.4.3 is co-installed with pyenv and the kernel is added so that both work. For details, refer to the article the other day (Jupyter Preferences Supplement #pythontokai). [^ 1]: IPython was also upgraded, so I updated it. Or rather ... See ↓
Octave seems to be able to download and install the binaries, but I installed it with Homebrew. I was able to install it using the same procedure, almost independent of the OSX version (although it will take some time).
$ brew update
$ brew tap homebrew/science
$ brew install octave
Also, Java was already in my environment, so there was no problem starting it.
$ octave --version
GNU Octave, version 3.8.2
Copyright (C) 2014 John W. Eaton and others.
This is free software; see the source code for copying conditions.
There is ABSOLUTELY NO WARRANTY; not even for MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE.
Octave was configured for "x86_64-apple-darwin13.4.0".
Additional information about Octave is available at http://www.octave.org.
Please contribute if you find this software useful.
For more information, visit http://www.octave.org/get-involved.html
Read http://www.octave.org/bugs.html to learn how to submit bug reports.
$
Jupyter's Octave kernel is provided as a Python package (Package Index> octave_kernel), so pip You can install it with the
command.
As a caveat, install it on Python3 so that there is no problem in handling Japanese. </ ins> (details below)
$ pyenv shell 3.4.3
$ pip install pip --upgrade
$ pip install octave_kernel
Multiple packages will be installed, including dependencies.
By the way, if you do pip install octave_kernel --upgrade
, it seems that it will be upgraded when the dependent packages can be updated [^ 3].
[^ 3]: Actually, IPython has now increased from 3.1.0 to 3.2.0 and is now "Wow" (^-^;
Installation confirmation [^ 5]:
ls ~/.pyenv/versions/3.4.3/lib/python3.4/site-packages/ | grep octave_kernel
octave_kernel-0.11.0-py3.4.egg
[^ 5]: When I installed it on Python2.7, I could see it with ʻimp.find_module ('octave_kernel')`, but with Python3.4 I couldn't see it (I was told I couldn't find it, (Mystery), so I'm just checking if the file exists.
This step is ** essentially unnecessary **. If the installation is successful, the kernel settings should be done [^ 2]. First, try [3. Operation check](# 3-% E5% 8B% 95% E4% BD% 9C% E7% A2% BA% E8% AA% 8D) in the next section and say "Kernel not found" If you get an error to that effect, perform the following manual kernel settings.
[^ 2]: When the kernel settings are done automatically, it seems that the config file is generated in / usr / local / share / jupyter / kernels / instead of in ~ / .ipython / kernels. The previously installed bash_kernel settings are there.
Even if you say manual setting of the kernel, all you have to do is create the kernel.json file yourself and place it in an appropriate location.
$ cd ~/.ipython/kernels
$ mkdir -p octave_kernel && cd octave_kernel
$ vi kernel.json
kernel.json (sample):
kernel.json
{
"argv": [
"/path/to/user_home/.pyenv/versions/3.4.3/bin/python",
"-m", "octave_kernel",
"-f", "{connection_file}"
],
"display_name": "Octave",
"language": "octave",
"name": "octave_kernel"
}
If you get an error saying "Kernel not found", see the previous section [2. Kernel settings](# 2-% E3% 82% AB% E3% 83% BC% E3% 83% 8D% E3% 83% AB. Go back to% E3% 81% AE% E8% A8% AD% E5% AE% 9A) and manually (re) configure the kernel.
$ ipython console --kernel=octave_kernel
IPython Console 3.2.0
In [1]: printf("Hello, World!\n")
gnuplot 5.0 patchlevel 0
Out[1]:
Hello, World!
In [2]: #Ctrl to exit+D
Do you really want to exit ([y]/n)?
What if gnuplot works when I just tried printf
? It feels like (^-^;
The kernel has been added properly:
Easy display confirmation:
By the way, the graph is drawn in SVG. Moreover, the size is automatically adjusted according to the width of the cell. If you change the width of the browser, it will be resized in real time. Somehow fun w
Even with Python2.7.x, octave_kernel can be installed successfully, but there was a problem that Japanese (or Unicode character string) was not handled properly and an internal error occurred when displaying.
I did some research, but octave_kernel.py or its source (defining MetaKernel
, which is a super class of ʻOctaveKernel`) [MetaKernel](https://pypi.python.org/ pypi / metakernel "metakernel 0.9.0: Python Package Index") It seems to be a problem on the side [^ 6], so I stopped chasing deeply.
Instead, isn't it okay if String is Python3 integrated with Unicode string? When I tried it, it worked as expected without any problems. It was good to coexist with the environment (^-^)
So, to use OctaveKernel (and other kernels that use MetaKernel), use Python3.
As a result, I installed octave_kernel once with 2.7.x and then installed it again with 3.x, but the kernel was successfully installed under (/ usr / local / share / jupyter / kernels). The kernel settings have been overwritten normally (if the environment is set). no problem. If you set it manually, you need to modify the path accordingly.
[^ 6]: Maybe it's a problem that can be solved just by putting a magic comment (# coding: utf-8
) at the beginning of the source ...
Recommended Posts