0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Python3.12でPyradiomicsを利用する

Posted at

はじめに

Python 3.12 がリリースされましたが、多くのライブラリがまだ対応していません。その中でも、Pyradiomics を使おうとするとインストールやビルドで以下のような問題が発生します。

AttributeError: module 'configparser' has no attribute 'SafeConfigParser'. Did you mean: 'ConfigParser'?

この記事では、Python 3.12 で Pyradiomics を正常に動かすための手順を解説します。

環境

  • OS: Ubuntu 22.04
  • Python: 3.12.9
  • 仮想環境: venv

解決法

まず、pip install pyradiomicsではなく、以下を実行します。

terminal
git clone https://github.com/Radiomics/pyradiomics.git  
cd pyradiomics  

次に、Pyradiomics の versioneer.py は古い構文を使っているため、修正が必要です。

修正 1: configparser.SafeConfigParser の修正

versioneer.py を開いて次の行を修正します。

変更前:

versioneer.py
parser = configparser.SafeConfigParser()  

変更後:

versioner.py
parser = configparser.ConfigParser()  

修正 2: readfp() を read_file() に変更

Python 3.2 以降では readfp() は read_file() に変更されています。

変更前:

versioneer.py
parser.readfp(f)

変更後:

versioneer.py
parser.read_file(f)  

pyradiomicsのインストール

cd ~/pyradiomicsを行い、以下を実行します。

terminal
pip install .  

まとめ

この記事ではPyradiomicsをPython3.12でインストールする方法を解説した。

0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?