Siril 1.4.x で Python を使うために

Siril

ここには、Ubuntu24 にインストールした、Siril 1.4.0で Python を使うメモと案内があります。
Python仮想環境を指定して、活性化させSirilを起動すると、Siril Pythonモジュールがインストールされ、Pythonスクリプトが使えます。

Python3.12 では、Siril Python スクリプトは完全に動きません

Python 3.13.7 を /usr/local へ入れ、仮想環境を作り、Siril Pythonスクリプトを動かします。

Ubuntu 24 へ Python 3.13.7 を入れて、仮想環境で Siril を使います

次のコマンドで、必要なツール類をダウンロードします。

$ sudo apt update
$ sudo apt install build-essential libbz2-dev libdb-dev \
  libreadline-dev libffi-dev libgdbm-dev liblzma-dev \
  libncursesw5-dev libsqlite3-dev libssl-dev \
  zlib1g-dev uuid-dev tk-dev

Python公式サイトの ダウンロードページ

$ tar xJfv Python-3.x.y.tar.xz

次のコマンドで、Pythonをビルドしてインストールします。
ビルドしたコマンドは /usr/local/bin にインストールされ、python3 コマンドまたは python3.x コマンドで起動できます。

$ cd Python-3.x.y
$ ./configure
$ make
$ sudo make install

Sirilを起動すると、Python仮想環境が作られます。以下の操作は必須ではありません。

pip と venv を使って仮想環境にパッケージをインストールする

venv ドキュメント
https://docs.python.org/3.10/library/venv.html

pip と venv を使って仮想環境にパッケージをインストールする
https://packaging.python.org/ja/latest/guides/installing-using-pip-and-virtual-environments/

ここを参考にして、Ubuntu24 に入れた Siril仮想環境を指定する。

$ python3.13 -m venv /home/$USERNAME/.local/share/siril/venv

Siril仮想環境にパッケージをインストールして使えるように、仮想環境を “activate” させます。

$ source /home/$USERNAME/.local/share/siril/venv/bin/activate
(venv) USERNAME@HOSTNAME:~$

『仮想環境が activate されたことを確認するには、 Python インタープリタの場所を確かめます。』

(venv) USERNAME@HOSTNAME:~$ which python
/home/$USERNAME/.local/share/siril/venv/bin/python

pipをインストールします。『pipは Python の参照モデルとなるパッケージマネージャです。仮想環境内でパッケージのインストールや更新に用いられます。』

pipを最新版にします。

(venv) USERNAME@HOSTNAME:~$ python3.13 -m pip install --upgrade pip

(venv) USERNAME@HOSTNAME:~$ python3.13 -m pip --version
pip 25.2 from /home/$USERNAME/.local/share/siril/venv/lib/python3.13/site-packages/pip (python 3.13)

Sirilを動かして、Siril Pythonスクリプトを使ってみましょう。必要なモジュールがインストールされるでしょう。


上記の作業でSiril Pythonスクリプトが動くならば、以下の操作は不必要です。

The virtual environment was not created successfully because ensurepip is not
available.  On Debian/Ubuntu systems, you need to install the python3-venv
package using the following command.

    apt install python3.12-venv

You may need to use sudo with that command.  After installing the python3-venv
package, recreate your virtual environment.

Failing command: /home/$USERNAME/.local/share/siril/venv/bin/python3
$ sudo apt install python3.12-venv
log: python仮想環境を準備しています: /home/$USERNAME/.local/share/siril/venv.
log: pythonモジュールが最新か確認しています...
log: Installing / updating python module in the background. This may take a few seconds...
/home/USERNAME/.local/share/siril/venv/bin/python3: No module named pip
log: Warning: unable to install or update the Siril python module.
$ sudo apt install python3-pip

tkfilebrowserは入っているかな?

python3.13 -m pip install tkfilebrowser
pip install tkfilebrowser

tk-dev が必要かも。
『tk-dev パッケージは、tkinter を使ったGUIアプリケーションを実行する場合に必要となります。』

Sirilを起動すると、以下のlogが表示されました。

Initializing FFTW multithreading support...
log: Welcome to siril v1.4.0-beta2
途中省略
log: Preparing python virtual environment: /home/USERNAME/.local/share/siril/venv.
途中省略
Last available version: 1.4.0-beta1
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Collecting numpy>=1.20.0 (from sirilpy==0.6.8)
  Downloading numpy-2.2.5-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (62 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 62.0/62.0 kB 1.3 MB/s eta 0:00:00
Collecting packaging>=21.0 (from sirilpy==0.6.8)
  Downloading packaging-25.0-py3-none-any.whl.metadata (3.3 kB)
Collecting requests>=2.25.0 (from sirilpy==0.6.8)
  Downloading requests-2.32.3-py3-none-any.whl.metadata (4.6 kB)
Collecting charset-normalizer<4,>=2 (from requests>=2.25.0->sirilpy==0.6.8)
  Downloading charset_normalizer-3.4.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (35 kB)
Collecting idna<4,>=2.5 (from requests>=2.25.0->sirilpy==0.6.8)
  Downloading idna-3.10-py3-none-any.whl.metadata (10 kB)
Collecting urllib3<3,>=1.21.1 (from requests>=2.25.0->sirilpy==0.6.8)
  Downloading urllib3-2.4.0-py3-none-any.whl.metadata (6.5 kB)
Collecting certifi>=2017.4.17 (from requests>=2.25.0->sirilpy==0.6.8)
  Downloading certifi-2025.4.26-py3-none-any.whl.metadata (2.5 kB)
Downloading numpy-2.2.5-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (16.1 MB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 16.1/16.1 MB 24.8 MB/s eta 0:00:00
Downloading packaging-25.0-py3-none-any.whl (66 kB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 66.5/66.5 kB 4.2 MB/s eta 0:00:00
Downloading requests-2.32.3-py3-none-any.whl (64 kB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 64.9/64.9 kB 6.5 MB/s eta 0:00:00
Downloading certifi-2025.4.26-py3-none-any.whl (159 kB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 159.6/159.6 kB 13.1 MB/s eta 0:00:00
Downloading charset_normalizer-3.4.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (148 kB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 148.6/148.6 kB 12.7 MB/s eta 0:00:00
Downloading idna-3.10-py3-none-any.whl (70 kB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 70.4/70.4 kB 5.3 MB/s eta 0:00:00
Downloading urllib3-2.4.0-py3-none-any.whl (128 kB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 128.7/128.7 kB 11.5 MB/s eta 0:00:00
Building wheels for collected packages: sirilpy
  Building wheel for sirilpy (pyproject.toml) ... done
  Created wheel for sirilpy: filename=sirilpy-0.6.8-py3-none-any.whl size=99430 sha256=6a7aac0b2f7050cd96f985f7da9f41e5a1d5ae5f60e40f044fa01e839f21631a
  Stored in directory: /tmp/pip-ephem-wheel-cache-lz3rs76b/wheels/b6/ee/15/50b9098e72d3de45dba69ef6dc47cd27d9dbf6d6caf2c23ae2
Successfully built sirilpy
Installing collected packages: urllib3, packaging, numpy, idna, charset-normalizer, certifi, requests, sirilpy
Successfully installed certifi-2025.4.26 charset-normalizer-3.4.2 idna-3.10 numpy-2.2.5 packaging-25.0 requests-2.32.3 sirilpy-0.6.8 urllib3-2.4.0
log: Python module is up-to-date

[ttkthemes] インストールできない。。。 Python-Tkが必要です。

ttkthemesとは?
https://pypi.org/project/ttkthemes/

使いたいPythonのバージョンに合わせた python-tk をインストールします。

$ sudo apt install python3.12-tk

次のコマンドでモジュールを入れなくても、Siril Pythonスクリプトを起動させると必要なモジュールが入ります。

$ python3 -m pip install ttkthemes ← これは行わない。Pythonスクリプトを実行する。
Collecting ttkthemes
  Using cached ttkthemes-3.2.2.tar.gz (891 kB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Collecting pillow (from ttkthemes)
  Downloading pillow-11.2.1-cp312-cp312-manylinux_2_28_x86_64.whl.metadata (8.9 kB)
Downloading pillow-11.2.1-cp312-cp312-manylinux_2_28_x86_64.whl (4.6 MB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 4.6/4.6 MB 20.7 MB/s eta 0:00:00
Building wheels for collected packages: ttkthemes
  Building wheel for ttkthemes (pyproject.toml) ... done
  Created wheel for ttkthemes: filename=ttkthemes-3.2.2-cp312-cp312-linux_x86_64.whl size=1794058 sha256=97cf69057ffe06ce204d35dd6d9918030ac6152b15fce05b9d8fbacbade5fb76
  Stored in directory: /home/minmin/.cache/pip/wheels/d4/69/04/0666a275c3b5cf4ed1036378c0ab691467df0a47a6379bda53
Successfully built ttkthemes
Installing collected packages: pillow, ttkthemes
Successfully installed pillow-11.2.1 ttkthemes-3.2.2

以下は必要の無い、パッケージでした。

$ python3 -m pip install setuptools
$ python3 -m pip install tkinter
ERROR: Could not find a version that satisfies the requirement tkinter (from versions: none)
$ python3 -m pip install pytk
Successfully installed appdirs-1.4.4 blessed-1.21.0 flyingcircus-0.1.4.1 pytk-0.0.2.1 setuptools-scm-8.3.1 wcwidth-0.2.13

Sirilの使い方などは、
Rich Stevenson – Deep Space Astro
彼の動画を参考にしています。Thank you very much.

彼がリリースした、”DSA-Star_Reduction.py”のソースを見たく、また使うために Python環境を整えるのが目的でした。
“DSA-Star_Reduction.py”では、StarNetとpixel mathを使ってるのですね。

Siril1.4 と Python の組み合わせが楽しくなってきています。Pythonは必須ですね。

コメント