개발

[Linux] 서버에서 jupyter notebook 사용하기

먼저 서버의 ip 주소를 확인한다.

ip addr show

 

config 파일을 생성한다.

jupyter notebook --generating-config

 

그럼 user home 경로에 다음과 같은 config 파일이 생성된다.

/data001/~~~~~~/.jupyter/jupyter_notebook_config.py

 

서버 비밀번호를 생성한다. (안해도됨)

터미널을 새로 열고 

ipython
In [1] : from notebook.auth import passwd
In [2] : passwd()
Enter password: 
Verify password:
Out [2] : 'argon2:~~~~~~' # 입력한 비밀번호를 암호화해서 반환해줌

In [3] : quit() # 빠져나옴

주의할 점은 비밀번호를 입력할 때, 아무것도 안뜬다. 잘 입력되고 있는 것이니 걱정하지 말고 입력 후에 Enter

암호화된 비밀번호를 복사해두고

 

주피터 서버 환경설정을 한다.

앞서 생성한 config 파일을 열어서 수정한다.

vi ~/.jupyter/jupyter_notebook_config.py

 

# Configuration file for jupyter-notebook

 

여기에 입력

 

#-------------------------------------------------------

# Application(SingletonConfigurable) configuration

#-------------------------------------------------------

 

# Configuration file for jupyter-notebook

c = get_config()

c.NotebookApp.allow_origin = '*' # 외부 접속 허용
c.NotebookApp.ip = '127.0.0.1' # 맨 처음에 찾아둔 ip 주소 입력
c.NotebookApp.open_browser = False # 시작 시 브라우저 실행 안함
c.NotebookApp.password = 'argon2:~~~~' # 복사해둔 암호 붙여넣기
c.NotebookApp.password_required = True
c.NotebookApp.port = 8888

#-------------------------------------------------------
# Application(SingletonConfigurable) configuration
#-------------------------------------------------------
~~~
:wq # 저장하고 빠져나오기

 

Jupyter Notebook 실행하기

jupyter notebook