LoginSignup
1
1

More than 1 year has passed since last update.

windowsでJupyter Notebookを用いてRDKitを使えるようにする方法

Last updated at Posted at 2022-07-28

Windows PCでもRDKitを便利に使いたい!
と思ったものの,設定になかなか手こずったのでその備忘録。

STEP1

まずはAnaconda3をインストールする。
インストールされたAnaconda Prompt(anaconda3)を開き,以下のコマンドを実行。

conda create -c rdkit -n my-rdkit-env rdkit

my-rdkit-envという仮想環境が作成される

STEP2

以下のコマンド例に従い,Anaconda Promptを立ち上げ、baseとmyenv両方にインストール。
(仮想環境の切り替えを相互に行うため、base仮想環境と自分の仮想環境両方にjupyterとenvironment_kernelsモジュールが必要らしい。)

conda activate base
(base) C:\Users\((User_name))>pip install jupyter environment_kernels
(base) C:\Users\((User_name))>conda deactivate

conda activate my-rdkit-env
(my-rdkit-env) C:\Users\((User_name))>pip install jupyter environment_kernels

スタートメニュー→Anadonda3 64-bit→Jupyter Notebook(64bit)で起動されるのはbase環境のJupyter。

STEP3

デフォルト仮想環境baseでJupyter初期設定ファイルを生成・編集。
Jupyerの初期設定ファイルは1つのはずなのでどちらでも良いはずだがbaseで行う。

(base) C:\Users\((User_name))>jupyter notebook --generate-config
Writing default config to: C:\Users\((User_name))\.jupyter\jupyter_notebook_config.py
作成したjupyter_notebook_config.pyをテキストエディタで開いて編集する。
## The kernel spec manager class to use. Should be a subclass of
#  `jupyter_client.kernelspec.KernelSpecManager`.
#  
#  The Api of KernelSpecManager is provisional and might change without warning
#  between this version of Jupyter and the next stable one.
#c.NotebookApp.kernel_spec_manager_class = 'jupyter_client.kernelspec.KernelSpecManager'

↑こんな感じの所を・・・

↓こんなん(下に二行書き加える)にする。

## The kernel spec manager class to use. Should be a subclass of
#  `jupyter_client.kernelspec.KernelSpecManager`.
#  
#  The Api of KernelSpecManager is provisional and might change without warning
#  between this version of Jupyter and the next stable one.
#  Default: 'jupyter_client.kernelspec.KernelSpecManager'
# c.NotebookApp.kernel_spec_manager_class = 'jupyter_client.kernelspec.KernelSpecManager'
c.NotebookApp.kernel_spec_manager_class='environment_kernels.EnvironmentKernelSpecManager'
c.EnvironmentKernelSpecManager.conda_env_dirs=['C:/Users/((User_name))/anaconda3/envs/']

['C:/Users/((User_name))/anaconda3/envs/']のところは自分でenvsを探してパスを確認して書く。

これでJupyter NotebookのNewのタブにEnvironment(conda_my-rdkit-env)が追加されたはずなので,そこから始めると,rdkitモジュールが読み込める‼Chem関数等々が使える‼

★終わり★

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1