Skip to main content

フレキシブル Python ランタイム機能の使用

フレキシブル Python ランタイム機能の概要

組み込み Python を実行する際、InterSystems IRIS はユーザがオペレーティング・システムの既定バージョンの Python を使用していると想定します。ただし、Microsoft Windows には、既定で Python は付属していません。また、現在の Windows 上の InterSystems IRIS インストーラでは Python はインストールされません。また、Python の新しいバージョンにアップグレードしたり、Anaconda のような代替ディストリビューションに切り替えたい場合もあります。

フレキシブル Python ランタイム機能を使用すると、InterSystems IRIS の組み込み Python で使用する Python バージョンを選択できます。

Important:

Microsoft Windows 上で組み込み Python と共に OpenSSL 3 を使用する必要がある場合は、Python 3.11 以上をインストールしてください。これにより、Python インストーラに含まれているバージョンの OpenSSL 3 がインストールされます。(組み込み Python で使用される OpenSSL のバージョンは、Windows オペレーティング・システムや InterSystems IRIS 自体で使用される他のバージョンとは独立しています。)

IntegratedMLAutoML 機能では、Python 3.11 以上を使用する必要があります。

フレキシブル Python ランタイム機能を使用するための準備は、次の 3 つの基本ステップで構成されます。

  1. 使用するバージョンの Python をインストールします。

  2. PythonRuntimeLibrary 構成設定を設定して、組み込み Python を実行する際に使用する Python ランタイム・ライブラリの場所を指定します。

    この場所は、オペレーティング・システム、Python バージョン、およびその他の要素によって異なります。

    Windows の例 : C:\Program Files\Python311\python3.dll (Windows 上の Python 3.11)

    Linux の例 : /usr/lib/x86_64-linux-gnu/libpython3.11.so.1.0 (x86 アーキテクチャの Ubuntu 22.04 上の Python 3.11)

    詳細は、"PythonRuntimeLibrary" を参照してください。

  3. PythonRuntimeLibraryVersion 構成設定を設定して、組み込み Python を実行する際に使用する Python ランタイム・ライブラリのバージョン番号を指定します。

    例 : 3.11

    詳細は、"PythonRuntimeLibraryVersion" を参照してください。

  4. 組み込み Python の sys.path 変数に、Python パッケージのインポートに必要な正しいディレクトリが含まれていることを確認します。

    "組み込み Python と sys.path" を参照してください。

いくつかの一般的なフレキシブル Python ランタイム・シナリオの手順を追った説明は、以下のセクションを参照してください。

組み込み Python と sys.path

組み込み Python を起動すると、これは sys.path 変数に含まれるディレクトリを使用して、インポートする Python パッケージを見つけます。

ご使用のオペレーティング・システムの既定バージョンの Python で、または Microsoft Windows で、組み込み Python を使用する場合、sys.path には既に、以下のような正しいディレクトリが含まれています。

  • <installdir>/lib/python (InterSystems IRIS 用に予約された Python パッケージ)

  • <installdir>/mgr/python (ユーザがインストールした Python パッケージ)

  • 既定の Python バージョンのグローバル・パッケージ・リポジトリ

    この場所は、オペレーティング・システム、Python バージョン、およびその他の要素によって異なります。

    Windows の例 : C:\Program Files\Python311\Lib\site-packages (Windows の Python 3.11)

    Linux の例 : /usr/local/lib/python3.10/dist-packages (Ubuntu 22.04 の Python 3.10)

Microsoft Windows 上の Python 3.11 では、組み込み Python の sys.path は以下のようになります。

USER>do ##class(%SYS.Python).Shell()
 
Python 3.11.9 (tags/v3.11.9:de54cf5, Apr  2 2024, 10:12:12) [MSC v.1938 64 bit (AMD64)] on win32
Type quit() or Ctrl-D to exit this shell.
>>> import sys
>>> sys.path
['C:\\Program Files\\Python311\\python311.zip', 'C:\\Program Files\\Python311\\DLLs', 
'C:\\Program Files\\Python311\\Lib', 'c:\\intersystems\\IRIS\\bin', 
'c:\\intersystems\\IRIS\\mgr\\python', 'c:\\intersystems\\IRIS\\lib\\python', 
'C:\\Program Files\\Python311', 'C:\\Program Files\\Python311\\Lib\\site-packages']
Important:

Microsoft Windows で、sys.path に、C:\Users\<username>\AppData\Local\Programs\Python\Python311 などのユーザ・ディレクトリ内のディレクトリが含まれる場合、現在のユーザにのみ Python がインストールされていることを示します。予期しない結果を避けるために、すべてのユーザに Python をインストールすることをお勧めします。

Ubuntu 22.04 上の既定バージョンの Python (3.10) では、組み込み Python の sys.path は以下のようになります。

USER>do ##class(%SYS.Python).Shell()

Python 3.10.12 (main, Nov 20 2023, 15:14:05) [GCC 11.4.0] on linux
Type quit() or Ctrl-D to exit this shell.
>>> import sys
>>> sys.path
['/usr/lib/python310.zip', '/usr/lib/python3.10', '/usr/lib/python3.10/lib-dynload', '/InterSystems/IRIS/lib/python', 
'/InterSystems/IRIS/mgr/python', '/usr/local/lib/python3.10/dist-packages', '/usr/lib/python3/dist-packages', 
'/usr/lib/python3.10/dist-packages']
Important:

Linux で、sys.path に、/home/<username>/.local/lib/python3.10/site-packages などのホーム・ディレクトリ内のディレクトリが含まれる場合、ローカル・パッケージ・リポジトリにパッケージがインストールされていることを示している可能性があります。例えば、--target 属性を指定せずに (および sudo を使用せずに) パッケージをインストールする場合、Python はホーム・ディレクトリ内のローカル・パッケージ・リポジトリにパッケージをインストールします。他のユーザがパッケージをインポートしようとすると、失敗します。

インターシステムズでは --target <installdir>/mgr/python オプションを使用することを推奨していますが、sudo を使用して --target 属性を省略してパッケージをインストールすると、パッケージはグローバル・パッケージ・リポジトリにインストールされます。これらのパッケージは、どのユーザでもインポートできます。

Python の代替ディストリビューションに切り替える場合、InterSystems IRIS はそのパッケージ・リポジトリの場所を認識できない可能性があります。InterSystems IRIS は、正しいディレクトリ、すなわちディレクトリ <installdir>/lib/pythoniris_site.py ファイルを含むように sys.path を調整するのに役立つツールを提供します。

iris_site.py ファイルは最も一般的なユース・ケースを網羅していますが、このファイルをカスタマイズする必要がある場合は、<installdir>/mgr/python ディレクトリにコピーしてください。これにより、InterSystems IRIS を新しいバージョンにアップグレードしても、構成が失われなくなります。このファイルのコメントに役に立つヒントが記載されていますので、お読みください。

Anaconda を使用している場合、InterSystems IRIS には、ニーズに合わせて編集できる例が付属しています。例えば、Linux 上で Anaconda を使用している場合は、ファイル iris_site_anaconda_ubuntu_linux_example.py<installdir>/lib/python ディレクトリから <installdir>/mgr/python ディレクトリにコピーして、名前を iris_site.py に変更します。次に、インストールに合わせてファイルのパス名を編集します。

Anaconda を使用している場合、InterSystems IRIS には、ニーズに合わせて編集できる例が付属しています。例えば、Linux 上で Anaconda を使用している場合は、ファイル iris_site_anaconda_ubuntu_linux_example.py<installdir>/lib/python ディレクトリから <installdir>/mgr/python ディレクトリにコピーして、名前を iris_site.py に変更します。次に、インストールに合わせてファイルのパス名を編集します。

例えば、Ubuntu 22.04 上の Anaconda の場合は、iris_site.py ファイルの最後の数行を編集して、実際のユーザ名に置き換えます。

    sys.path = sys.path + __sitegetsitepackages(['/home/<username>/anaconda3'])
    sys.path = sys.path + ["/home/<username>/anaconda3/lib/python3.11/lib-dynload"]
    sys.path = ["/home/<username>/anaconda3/lib/python3.11"] + sys.path
    sys.path = ["/home/<username>/anaconda3/lib/python311.zip"] + sys.path

上記の iris_site.py では、組み込み Python の sys.path は以下のようになります。

USER>do ##class(%SYS.Python).Shell()

Python 3.11.7 (main, Dec 15 2023, 18:24:52) [GCC 11.2.0] on linux
Type quit() or Ctrl-D to exit this shell.
>>> import sys
>>> sys.path                                     
['/home/<username>/anaconda3/lib/python311.zip', '/home/<username>/anaconda3/lib/python3.11', 
'/home/<username>/anaconda3/lib/python311.zip', '/home/<username>/anaconda3/lib/python3.11', 
'/home/<username>/anaconda3/lib/python3.11/lib-dynload', '/InterSystems/IRIS/mgr/python', 
'/InterSystems/IRIS/lib/python', '/home/<username>/anaconda3/lib/python3.11/site-packages', 
'/home/<username>/anaconda3/lib/python3.11/lib-dynload']

繰り返しますが、上記の例の <username> は、実際のユーザ名にします。

フレキシブル Python ランタイムに適した sys.path にするのに、何回かの反復処理が必要になることがあります。InterSystems IRIS 外で Python を起動し、その sys.path を組み込み Python 内の sys.path と比較して、想定されるディレクトリがすべて含まれていることを確認するとよいでしょう。

Note:

PythonRuntimeLibrary および PythonRuntimeLibraryVersion 構成設定または iris_site.py に対する変更は、新しいセッションの開始時に有効になります。InterSystems IRIS を再起動する必要はありません。

Python バージョン情報の確認

フレキシブル Python ランタイム機能を使用している場合、組み込み Python が使用している Python のバージョンと、システムで使用されている既定のバージョンを確認すると便利なことがあります。そのためには、%SYS.PythonOpens in a new tab クラスの GetPythonInfo() メソッドを呼び出すと簡単です。

以下の例は、x86 アーキテクチャの Ubuntu 22.04 で、使用されている Python ランタイム・ライブラリが /usr/lib/x86_64-linux-gnu/libpython3.11.so.1.0、実行されている組み込み Python のバージョンが 3.11.0rc1、システム・バージョンが 3.10.12 であることを示しています。

USER>do ##class(%SYS.Python).GetPythonInfo(.info)
 
USER>zw info
info("AllowNonSystemPythonForIntegratedML")=0
info("CPF_PythonPath")=""
info("CPF_PythonRuntimeLibrary")="/usr/lib/x86_64-linux-gnu/libpython3.11.so.1.0"
info("CPF_PythonRuntimeLibraryVersion")=3.11
info("IRISInsidePython")=0
info("PythonInsideIRIS")=2
info("RunningLibrary")="/usr/lib/x86_64-linux-gnu/libpython3.11.so.1.0"
info("RunningVersion")="3.11.0rc1 (main, Aug 12 2022, 10:02:14) [GCC 11.2.0]"
info("SystemPath")="/usr/lib/python3.10/config-3.10-x86_64-linux-gnu"
info("SystemVersion")="3.10.12 (main, Nov 20 2023, 15:14:05) [GCC 11.4.0]"
info("SystemVersionShort")="3.10.12"
info("iris_site.py_platform")="lnxubuntu2204x64"

この情報は、オペレーティング・システム、Python バージョン、およびその他の要素によって異なります。

フレキシブル Python ランタイムの例 : Windows の Python 3.11

Microsoft Windows には、既定で Python は付属していません。また、現在の Windows 向けの InterSystems IRIS インストーラでは Python はインストールされません。ユーザ自身で Python をダウンロードしてインストールする必要があります。

Important:

組み込み Python と共に OpenSSL 3 を使用する必要がある場合、Python 3.11 以上をインストールすると OpenSSL 3 もインストールされます。組み込み Python で使用される OpenSSL のバージョンは、Windows オペレーティング・システムや InterSystems IRIS 自体で使用される他のバージョンとは独立しています。

以下の例は、組み込み Python で使用される OpenSSL バージョンを特定する方法を示しています。

USER>do ##class(%SYS.Python).Shell()
 
Python 3.11.9 (tags/v3.11.9:de54cf5, Apr  2 2024, 10:12:12) [MSC v.1938 64 bit (AMD64)] on win32
Type quit() or Ctrl-D to exit this shell.
>>> import ssl
>>> ssl.OPENSSL_VERSION
'OpenSSL 3.0.13 30 Jan 2024'

以下の例は、Windows 上で Python 3.11 をインストールして InterSystems IRIS で使用する方法を示しています。

  1. Https://www.python.org/downloads/Opens in a new tab から Python 3.11 をダウンロードします。

  2. Python インストーラを起動します。

  3. [Customize Installation] をクリックします。

  4. [Advanced Options] 画面に到達するまで [Next] をクリックします。

  5. すべてのユーザに Python をインストールするオプションを選択します。

  6. [Install] をクリックします。

  7. InterSystems IRIS の管理ポータルで、[システム管理][構成][追加の設定][メモリ詳細] に移動します。

  8. [メモリ詳細設定] ページの [PythonRuntimeLibrary] の行で、[編集] をクリックします。

  9. C:\Program Files\Python311\python3.dll」と入力します。

    Important:

    python3.dll が、C:\Users\<username>\AppData\Local\Programs\Python\Python311 などのユーザ・ディレクトリ内のフォルダに置かれている場合、現在のユーザにのみ Python がインストールされていることを示します。予期しない結果を避けるために、すべてのユーザに Python をインストールすることをお勧めします。

  10. [保存] をクリックします。

  11. [メモリ詳細設定] ページの [PythonRuntimeLibraryVersion] の行で、[編集] をクリックします。

  12. 3.11」と入力します。

  13. [保存] をクリックします。

  14. ターミナルから組み込み Python を起動し、sys.path に Python 3.11 パッケージ・ディレクトリが含まれていることを確認します。

    USER>do ##class(%SYS.Python).Shell()
     
    Python 3.11.9 (tags/v3.11.9:de54cf5, Apr  2 2024, 10:12:12) [MSC v.1938 64 bit (AMD64)] on win32
    Type quit() or Ctrl-D to exit this shell.
    >>> import sys
    >>> sys.path
    ['C:\\Program Files\\Python311\\python311.zip', 'C:\\Program Files\\Python311\\DLLs', 
    'C:\\Program Files\\Python311\\Lib', 'c:\\intersystems\\IRIS\\bin', 
    'c:\\intersystems\\IRIS\\mgr\\python', 'c:\\intersystems\\IRIS\\lib\\python', 
    'C:\\Program Files\\Python311', 'C:\\Program Files\\Python311\\Lib\\site-packages']
    
  15. ターミナルから %SYS.PythonOpens in a new tab クラスの GetPythonInfo() メソッドを使用して、Python のバージョン情報を表示します。

    USER>do ##class(%SYS.Python).GetPythonInfo(.info)
     
    USER>zw info
    info("AllowNonSystemPythonForIntegratedML")=0
    info("CPF_PythonPath")=""
    info("CPF_PythonRuntimeLibrary")="C:\Program Files\Python311\python3.dll"
    info("CPF_PythonRuntimeLibraryVersion")=3.11
    info("IRISInsidePython")=0
    info("PythonInsideIRIS")=16
    info("RunningLibrary")="C:\Program Files\Python311\python3.dll"
    info("RunningVersion")="3.11.9 (tags/v3.11.9:de54cf5, Apr  2 2024, 10:12:12) [MSC v.1938 64 bit (AMD64)]"
    info("SystemPath")="F:\AllPythons\python.3.9.13\tools\"
    info("SystemVersion")="3.9.13 (tags/v3.9.13:6de2ca5, May 17 2022, 16:36:42) [MSC v.1929 64 bit (AMD64)]"
    info("SystemVersionShort")="3.9.13"
    info("iris_site.py_platform")="winamd64"
    

    この例は、使用されている Python ランタイム・ライブラリが C:\Program Files\Python311\python3.dll、実行されている組み込み Python のバージョンが 3.11.9 であることを示しています。SystemVersion は、Windows では関係ありません。

フレキシブル Python ランタイムの例 : Ubuntu 22.04 の Python 3.11

Python 3.10 は、Ubuntu 22.04 の Python の既定バージョンです。この例では、組み込み Python で Python 3.11 を使用する方法を示します。

Note:

この例は、x86 アーキテクチャの Ubuntu 22.04 の場合です。ARM アーキテクチャの場合、ファイル名とディレクトリ名は異なることがあります。

  1. コマンド行から Python 3.11 をインストールします。

    $ sudo apt install python3.11-full

  2. Python 3.11 libpython.so 共有ライブラリをインストールします。

    $ sudo apt install libpython3.11

  3. InterSystems IRIS の管理ポータルで、[システム管理][構成][追加の設定][メモリ詳細] に移動します。

  4. [メモリ詳細設定] ページの [PythonRuntimeLibrary] の行で、[編集] をクリックします。

  5. /Usr/lib/x86_64-linux-gnu/libpython3.11.so.1.0」と入力します。

  6. [保存] をクリックします。

  7. [メモリ詳細設定] ページの [PythonRuntimeLibraryVersion] の行で、[編集] をクリックします。

  8. 3.11」と入力します。

  9. [保存] をクリックします。

  10. ターミナルから組み込み Python を起動し、sys.path に Python 3.11 パッケージ・ディレクトリが含まれていることを確認します。

    USER>do ##class(%SYS.Python).Shell()
    
    Python 3.11.0rc1 (main, Aug 12 2022, 10:02:14) [GCC 11.2.0] on linux
    Type quit() or Ctrl-D to exit this shell.
    >>> import sys
    >>> sys.path
    ['/usr/lib/python311.zip', '/usr/lib/python3.11', '/usr/lib/python3.11/lib-dynload', '/InterSystems/IRIS/mgr/python', 
    '/InterSystems/IRIS/lib/python', '/usr/local/lib/python3.11/dist-packages', '/usr/lib/python3/dist-packages', 
    '/usr/lib/python3.11/dist-packages']
    
  11. ターミナルから %SYS.PythonOpens in a new tab クラスの GetPythonInfo() メソッドを使用して、Python のバージョン情報を表示します。

    USER>do ##class(%SYS.Python).GetPythonInfo(.info)
    
    USER>zw info
    info("AllowNonSystemPythonForIntegratedML")=0
    info("CPF_PythonPath")=""
    info("CPF_PythonRuntimeLibrary")="/usr/lib/x86_64-linux-gnu/libpython3.11.so.1.0"
    info("CPF_PythonRuntimeLibraryVersion")=3.11
    info("IRISInsidePython")=0
    info("PythonInsideIRIS")=2
    info("RunningLibrary")="/usr/lib/x86_64-linux-gnu/libpython3.11.so.1.0"
    info("RunningVersion")="3.11.0rc1 (main, Aug 12 2022, 10:02:14) [GCC 11.2.0]"
    info("SystemPath")="/usr/lib/python3.10/config-3.10-x86_64-linux-gnu"
    info("SystemVersion")="3.10.12 (main, Nov 20 2023, 15:14:05) [GCC 11.4.0]"
    info("SystemVersionShort")="3.10.12"
    info("iris_site.py_platform")="lnxubuntu2204x64"
    

    この例は、使用されている Python ランタイム・ライブラリが /usr/lib/x86_64-linux-gnu/libpython3.11.so.1.0、実行されている組み込み Python のバージョンが 3.11.0rc1、システム・バージョンが 3.10.12 であることを示しています。

フレキシブル Python ランタイムの例 : Windows の Anaconda

Anaconda は、一般的にデータ・サイエンスや人工知能アプリケーションに使用される Python ベースのプラットフォームです。この例では、Windows で Anaconda を使用する方法を示します。Anaconda はすべてのユーザにインストールすることをお勧めします。

  1. Https://anaconda.com/downloadOpens in a new tab から Anaconda をダウンロードします。

  2. Anaconda インストーラを起動し、[Welcome] 画面で [Next] をクリックします。

  3. ライセンス契約に同意します。

  4. [Select Installation Type] でインストール対象として [All Users] を選択します。

  5. [Choose Install Location][Destination Folder] は、既定の C:\ProgramData\anaconda3 のままにします。

  6. [Advanced Installation Options][Register Anaconda3 as the System Python] の選択を解除します。

  7. [Install] をクリックして、インストール・プロセスを開始します。

  8. InterSystems IRIS の管理ポータルで、[システム管理][構成][追加の設定][メモリ詳細] に移動します。

  9. [メモリ詳細設定] ページの [PythonRuntimeLibrary] の行で、[編集] をクリックします。

  10. C:\ProgramData\anaconda3\python312.dll」と入力します。

  11. [保存] をクリックします。

  12. [メモリ詳細設定] ページの [PythonRuntimeLibraryVersion] の行で、[編集] をクリックします。

  13. 3.12」と入力します。

  14. [保存] をクリックします。

  15. ファイルiris_site_anaconda_windows_example.py<installdir>/lib/python ディレクトリから <installdir>/mgr/python ディレクトリにコピーして、名前を iris_site.py に変更します。

    Anaconda を既定の場所にインストールした場合、ファイルを変更する必要はありません。

  16. ターミナルから組み込み Python を起動し、sys.path に Anaconda パッケージ・リポジトリが含まれていることを確認します。

    USER>do ##class(%SYS.Python).Shell()
     
    Python 3.12.4 | packaged by Anaconda, Inc. | (main, Jun 18 2024, 15:03:56) [MSC v.1929 64 bit (AMD64)] on win32
    Type quit() or Ctrl-D to exit this shell.
    >>> import sys
    >>> sys.path
    ['C:\\ProgramData\\anaconda3\\python312.zip', 'C:\\ProgramData\\anaconda3\\DLLs', 
    'C:\\ProgramData\\anaconda3\\Lib', \'c:\\intersystems\\IRIS\\bin', 
    'c:\\intersystems\\IRIS\\mgr\\python', 'c:\\intersystems\\IRIS\\lib\\python', 
    'C:\\ProgramData\\anaconda3', 'C:\\ProgramData\\anaconda3\\Lib\\site-packages', 
    'C:\\ProgramData\\anaconda3\\Lib\\site-packages\\win32', 'C:\\ProgramData\\anaconda3\\Lib\\site-packages\\win32\\lib', 
    'C:\\ProgramData\\anaconda3\\Lib\\site-packages\\Pythonwin']
    
  17. ターミナルから %SYS.PythonOpens in a new tab クラスの GetPythonInfo() メソッドを使用して、Python のバージョン情報を表示します。

    USER>do ##class(%SYS.Python).GetPythonInfo(.info)
     
    USER>zw info
    info("AllowNonSystemPythonForIntegratedML")=0
    info("CPF_PythonPath")=""
    info("CPF_PythonRuntimeLibrary")="C:\ProgramData\anaconda3\python312.dll"
    info("CPF_PythonRuntimeLibraryVersion")=3.12
    info("IRISInsidePython")=0
    info("PythonInsideIRIS")=1
    info("RunningLibrary")="C:\ProgramData\anaconda3\python312.dll"
    info("RunningVersion")="3.12.4 | packaged by Anaconda, Inc. | (main, Jun 18 2024, 15:03:56) [MSC v.1929 64 bit (AMD64)]"
    info("SystemPath")="F:\AllPythons\python.3.9.13\tools\"
    info("SystemVersion")="3.9.13 (tags/v3.9.13:6de2ca5, May 17 2022, 16:36:42) [MSC v.1929 64 bit (AMD64)]"
    info("SystemVersionShort")="3.9.13"
    info("iris_site.py_platform")="winamd64"
    

    この例は、使用されている Python ランタイム・ライブラリが C:\ProgramData\anaconda3\python312.dll、実行されている組み込み Python のバージョンが 3.12.4 であることを示しています。SystemVersion は、Windows では関係ありません。

フレキシブル Python ランタイムの例 : Ubuntu 22.04 の Anaconda

Anaconda は、一般的にデータ・サイエンスや人工知能アプリケーションに使用される Python ベースのプラットフォームです。この例では、Ubuntu 22.04 で Anaconda を使用する方法を示します。ユーザ用にインストールを行うことをお勧めします。

Note:

この例は、x86 アーキテクチャの Ubuntu 22.04 の場合です。ARM アーキテクチャの場合、ファイル名とディレクトリ名は異なることがあります。

  1. Anaconda をダウンロードします。

    curl -O https://repo.anaconda.com/archive/Anaconda3-2024.02-1-Linux-x86_64.sh

  2. コマンド行から、以下のように Anaconda インストール・スクリプトを実行します。

    $ sh Anaconda3-2024.02-1-Linux-x86_64.sh

  3. ライセンス条項に同意します。

  4. インストール・ディレクトリを入力するよう求められたら、「/home/<username>/anaconda3」と入力します。<username> は Ubuntu ユーザ名です。

  5. 起動時に conda を有効化するかどうか尋ねられます。この例では、「no」と入力します。

  6. これで、Anaconda のインストール・プロセスは終了です。

    Thank you for installing Anaconda3! というメッセージが表示されます。

  7. Anaconda を有効にします。

    $ source /home/<username>/anaconda3/bin/activate

    実際のユーザ名に置き換えてください。

  8. Anaconda を初期化します。

    $ conda init

  9. InterSystems IRIS の管理ポータルで、[システム管理][構成][追加の設定][メモリ詳細] に移動します。

  10. [メモリ詳細設定] ページの [PythonRuntimeLibrary] の行で、[編集] をクリックします。

  11. /Home/<username>/anaconda3/lib/libpython3.11.so.1.0」と入力します。

    実際のユーザ名に置き換えてください。

  12. [保存] をクリックします。

  13. [メモリ詳細設定] ページの [PythonRuntimeLibraryVersion] の行で、[編集] をクリックします。

  14. 3.11」と入力します。

  15. [保存] をクリックします。

  16. ファイルiris_site_anaconda_ubuntu_linux_example.py<installdir>/lib/python ディレクトリから <installdir>/mgr/python ディレクトリにコピーして、名前を iris_site.py に変更します。

  17. iris_site.py ファイルの最後の数行を編集して、実際のユーザ名に置き換えます。

        sys.path = sys.path + __sitegetsitepackages(['/home/<username>/anaconda3'])
        sys.path = sys.path + ["/home/<username>/anaconda3/lib/python3.11/lib-dynload"]
        sys.path = ["/home/<username>/anaconda3/lib/python3.11"] + sys.path
        sys.path = ["/home/<username>/anaconda3/lib/python311.zip"] + sys.path
    
  18. ターミナルから組み込み Python を起動し、sys.path に Anaconda パッケージ・リポジトリが含まれていることを確認します。

    USER>do ##class(%SYS.Python).Shell()
    
    Python 3.11.7 (main, Dec 15 2023, 18:24:52) [GCC 11.2.0] on linux
    Type quit() or Ctrl-D to exit this shell.
    >>> import sys
    >>> sys.path                                     
    ['/home/<username>/anaconda3/lib/python311.zip', '/home/<username>/anaconda3/lib/python3.11', 
    '/home/<username>/anaconda3/lib/python311.zip', '/home/<username>/anaconda3/lib/python3.11', 
    '/home/<username>/anaconda3/lib/python3.11/lib-dynload', '/InterSystems/IRIS/mgr/python', 
    '/InterSystems/IRIS/lib/python', '/home/<username>/anaconda3/lib/python3.11/site-packages', 
    '/home/<username>/anaconda3/lib/python3.11/lib-dynload']
    

    上記の例の <username> は、実際のユーザ名にします。

  19. ターミナルから %SYS.PythonOpens in a new tab クラスの GetPythonInfo() メソッドを使用して、Python のバージョン情報を表示します。

    USER>do ##class(%SYS.Python).GetPythonInfo(.info)
     
    USER>zw info
    info("AllowNonSystemPythonForIntegratedML")=0
    info("CPF_PythonPath")=""
    info("CPF_PythonRuntimeLibrary")="/home/<username>/anaconda3/lib/libpython3.11.so"
    info("CPF_PythonRuntimeLibraryVersion")=3.11
    info("IRISInsidePython")=0
    info("PythonInsideIRIS")=3
    info("RunningLibrary")="/home/<username>/anaconda3/lib/libpython3.11.so"
    info("RunningVersion")="3.11.7 (main, Dec 15 2023, 18:24:52) [GCC 11.2.0]"
    info("SystemPath")="/usr/lib/python3.10/config-3.10-x86_64-linux-gnu"
    info("SystemVersion")="3.10.12 (main, Nov 20 2023, 15:14:05) [GCC 11.4.0]"
    info("SystemVersionShort")="3.10.12"
    info("iris_site.py_platform")="lnxubuntu2204x64"info("PythonInsideIRIS")=2
    info("RunningLibrary")="/usr/lib/x86_64-linux-gnu/libpython3.11.so.1.0"
    info("RunningVersion")="3.11.0rc1 (main, Aug 12 2022, 10:02:14) [GCC 11.2.0]"
    info("SystemPath")="/usr/lib/python3.10/config-3.10-x86_64-linux-gnu"
    info("SystemVersion")="3.10.12 (main, Nov 20 2023, 15:14:05) [GCC 11.4.0]"
    info("SystemVersionShort")="3.10.12"
    info("iris_site.py_platform")="lnxubuntu2204x64"
    

    繰り返しますが、上記の例の <username> は、実際のユーザ名にします。

    この例は、使用されている Python ランタイム・ライブラリが /home/<username>/anaconda3/lib/libpython3.11.so、実行されている組み込み Python のバージョンが 3.11.7、システム・バージョンが 3.10.12 であることを示しています。

FeedbackOpens in a new tab