Jupyter NoteBook 에 C# 설치하기



Jupyter NoteBook 설치방법 링크 :  http://melonicedlatte.com/2017/01/25/145615.html

Jupyter NoteBook 다른 언어 설치 방법 링크 : http://melonicedlatte.com/2017/02/20/064648.html


https://github.com/zabirauf/icsharp

위의 링크를 참조해서 Jupyter NoteBook에 C# 을 설치하는 과정을 살펴보았습니다.
학교에서 곧 윈도우 프로그래밍 언어로 C# 을 시작하는데 그 때를 위해서 미리 설치해두었습니다.

링크에는 Mac Os 와 윈도우의 설치 방법도 나와있는데요.
저는 서버컴퓨터로 Ubuntu를 사용하기 때문에 Linux 설치 방법을 따라 가겠습니다.  

원 명령어에 sudo 를 추가하였습니다. 
루트권한이 없으면 설치되지 않더라구요.


아래와 같이 C# 을 추가해보려고 합니다. 




Interactive C# Notebook

ICSharp is an C# language kernel for Jupyter. It allows users to use Jupyter's Notebook frontend, except where Jupyter executes python code, ICSharp can execute C# code. It is based on Roslyn REPL engine of scriptcs., so all the goodies of scriptcs comes along with it.

This is on top of all of Jupyter's other frontend features like Markdown rendering, HTML rendering, saving notebooks for later use and even the ability to view ICSharp Notebooks in Jupyter's NBViewer.


ICSharp 는 Jupyter 의 C# 커널이고, Roslyn REPL engine 의 기반을 두고 있다고 한다는데 그 부분까지는 이해를 잘 못하겠습니다.
리눅스 수업을 듣기는 했지만 아직 리눅스의 커널 개념이나 구조를 잘 이해를 못하고 있습니다. 
저는 설치방법만 설명드리겠습니다. 

저 같은 경우에는 Anaconda 를 사용하지 않기 때문에 설명 중에서 필요한 부분만 뽑아서 설치를 했습니다. 


>> 설치방법 

# add debian repository
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF
# write the echoed line into the file on the rightsudo 
echo "deb http://download.mono-project.com/repo/debian wheezy main" | sudo tee /etc/apt/sources.list.d/mono-xamarin.list
# update packets - this installs mono..
sudo apt-get update -y
# The package mono-complete should be installed to install everything - this should cover most cases of “assembly not found” errors.
sudo apt-get install mono-complete -y
# mono-dbg -  has the .mdb files which mono uses for stack traces in managed code... so that exceptions are logged properly.
sudo apt-get install mono-dbg -y                 
# mono-runtime-db - has the debug info gdb uses for bugs in mono itself
sudo apt-get install mono-runtime-dbg -y
sudo mozroots --import --machine --syncmono --versionecho 
"Mono Install finished!"

원래 글에는 If Mono is not installed, then create installmono.sh in a text editor and run it with bash installmono.sh 라고 언급되어있습니다.
아마 파일을 만들어서 저 소스들을 넣은 다음에 한 번에 실행하는 방법을 선택 한 것 같습니다.

그래서 echo 로 어디까지 설치가 되고 있나 말해주고 있는 것 같은데 저는 그냥 하나씩 명령어를 입력해서 설치했습니다.
( echo 는 입력 안하셔도 될 것 같습니다. )



Compile ICSharp

sudo apt-get install git -y
#checkout with submodules:
sudo git clone --recursive https://github.com/zabirauf/icsharp.gitcd icsharpsudo bash ./build.sh       

다음으로 위의 명령어를 차례대로 입력해줍니다. 



Compile ICsharp

Get the sources from Github (including submodules):

git clone --recursive https://github.com/zabirauf/icsharp

Open the solution iCSharp.sln in Visual Studio. Switch the configuration to Release. Build the Solution.


위의 명령어를 입력해줍니다.  

  

Inside the icsharp directory containing the code, run:

jupyter kernelspec install kernel-spec --name=csharp

This command copies the kernel-spec directory in your ProgramDataJupyterkernelswhere Jupyter looks for kernels, and renames it as csharp. Check that csharp is listed in:  

    

  위의 명령어를 입력해서 kernel 에 cshrp 를 설치합니다.   

  

jupyter kernelspec list

Now just launch jupyter notebook and C# will be available in the Kernel list once you opened a notebook.


그 다음으로 위의 명령어를 입력하여 결과를 확인해줍니다. 


csharp 가 추가되었습니다. 


Jupyter Notebook 을 다시 실행시켜주면??


C# 을 추가해주었습니다. !!