본문 바로가기
프로그래밍 언어/Mathematica

[Mathematica] Jupyter 노트북으로 Mathematica 사용하기

by Physics 2022. 3. 27.
728x90

현재 미국에서 한국에 있는 리눅스 서버를 사용하고 있다. 해당 리눅스 서버에서 x-window를 통해 매스메티카 노트북을 사용하는데, 문제는 프론트 엔드인 메스메티카 노트북이 너무 느리다라는 것이다. 하지만 반대로 Jupyter의 경우 미국에서 한국에 있는 서버를 사용하는데 크게 불편함을 느끼지 못했다. 그래서, 메스메티카를 Jupyter 노트북을 통해 사용하고자 한다. 만약 당신이 Mathemtica를 원격으로 사용한다면, 해당 포스트는 도움이 크게 될 것이라고 생각한다. 


1. 준비사항 

Jupyter 노트북으로 Mathematica를 사용하기 위해선, 아래의 준비물이 필요하다. 
  a. Mathematica Wolfram Engine*
    •  만일 Mathematica 12이상의 버전이 설치되어있다면 이미 Wolfram script, wolfram engine이 설치되어 있다. 
  b. Jupyter Notebook 
    •  Download Website: 
      - Anaconda: https://www.anaconda.com/   
      - Jupyter notebook: https://jupyter.org/ 
     python도 같이 설치를 하고자 한다면, Anaconda를 설치하는 것을 추천한다. 
  c. WolframLanguageForJupyter 
    • Github Website: https://github.com/WolframResearch/WolframLanguageForJupyter    
    • Wolfram Engine을 jupyter notebook에 실행할 수 있도록 해주는 프로그램 

 

2. 설치 

 1) git을 통한 WolframLangaugeForJupyter 다운로드 

$ git clone https://github.com/WolframResearch/WolframLanguageForJupyter.git

- 만일 OS가 Windows라면, 아래처럼 https://github.com/WolframResearch/WolframLanguageForJupyter에서  zip 파일을 다운받은 후, 압축을 풀자. 

2) 아래의 명령어를 통해 Wolfram engine을 Jupyter에서 사용하도록 함

$ cd WolframLanguageForJupyter
$ ./configure-jupyter.wls add

Note: 만일 OS가 Windows일 경우에는 1)에서 받은 압축을 푼 디렉토리로 이동하자. 그 후 powershell이나 cmd 등의 CLI 환경에서 위 명령어를 실행하면 된다.  

그 후, 원격으로 Mathematica가 설치된 서버에서 Jupyter Lab을 실행시키면, 아래와 같이 Wolfram Language가 설치되어있음을 확인할 수 있다. 이후 Jupyter notebook 혹은 Jupyter Lab 등에서 wolfram engine을 사용할 수 있다. 

 

3. 

2번까지 완성을 하면, jupyter 노트북에서 Wolfram Engine(이하 Mathemtica로 통일)을 사용할 순 있지만, Mathematica Notebook에서 사용할 수 있었던 자동완성 (Auto completion)을 사용할 순 없다. 여기서 우리가 사용할 수 있는 두 가지 옵션이 있다. 

   a. JWLS (Jupyter notebook for Wolfram Language Script)  
   b. IWolfram: https://github.com/mmatera/iwolfram

하지만, 해당 자동완성 기능을 사용할 수 있는 플러그인(?)인 JWLS (Jupyter notebook for Wolfram Language Script)이 있다.  

- Web site: https://github.com/Ludwiggle/JWLS 
- https://community.wolfram.com/groups/-/m/t/1690413

GPU?

https://community.wolfram.com/groups/-/m/t/1884517

Graphic interaction 

https://community.wolfram.com/groups/-/m/t/1690413

https://mathematica.stackexchange.com/questions/199736/interactive-plots-output-in-jupyter-based-interface

728x90

댓글