2
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?

Git Bash × asdf × Python3.13でインストールを頑張ろうとして沼った話

Last updated at Posted at 2025-04-19

こんにちは。

株式会社KANGEN Holdingsの野中康生です!

はじめに

最近、現場で Windows を使うようになりました。これまでの現場ではMacを使っての開発ばかりだったので、Windowsでの開発経験はほぼありません。そしてこれまではPythonのバージョン管理に asdf を使ってきており、「Windows にgit Bash入れているし、同じ感じでやれるっしょ」と思ってたら…

ハマってしまいました・・・。

今回は、その沼から脱出した内容を備忘録として残しておきます。

発端:Python 3.13 を asdf 経由で入れようとした

あるプロジェクトではPython3.10系を使用していて、別プロジェクトではPython3.13系を使用することになったので、Git Bashを使ってasdf経由でPython 3.13を導入しようとしていました。

最初は、Git Bash上にasdfをcloneしてきて、インストールみたいな流れでいけるだろうと思ってました。

ところが、asdfコマンドを入れ、パスを通した上で、いざ

asdf install python 3.13.2

を実行するとインストール時に次のようなエラーに直面しました:

error: implicit declaration of function 'setenv'

これはどうやら、Windows環境では setenvが標準で使えないために発生するビルドエラーらしいです。

asdfの公式HPを見ると推奨のパッケージマネージャーにHomebrewに加えて、Pacmanの記載があったので、

MSYS2をインストールしました。で以下のようにインストールしました。

pacman -Sy --noconfirm
pacman -S --noconfirm base-devel mingw-w64-x86_64-toolchain \
  mingw-w64-x86_64-openssl \
  mingw-w64-x86_64-zlib \
  mingw-w64-x86_64-xz \
  mingw-w64-x86_64-bzip2 \
  mingw-w64-x86_64-readline \
  git curl

ただし、3.13系をインストール時のエラー内容は変わらずでした・・・。

解決策

結局はWindowsにUbuntuを導入し、そこでasdfをインストールしたらすぐに解決できました。

1. Ubuntuのインストール & 初期設定

まずはコマンドプロンプトやPowerShellで以下のコマンドを実行し、Ubuntuをインストールします。

wsl --install

Ubuntuを起動して、ユーザー名とパスワードを設定します。

2. 依存パッケージのインストール

asdfのインストールに必要なパッケージをよしなにインストールします。

sudo apt update && sudo apt install -y \
  make build-essential libssl-dev zlib1g-dev \
  libbz2-dev libreadline-dev libsqlite3-dev curl \
  libncursesw5-dev xz-utils tk-dev libxml2-dev \
  libxmlsec1-dev libffi-dev liblzma-dev \
  uuid-dev libgdbm-dev libnss3-dev libedit-dev

3. asdfのインストール

そして、asdfをクローンして、パスを通します。

# 調べた時点での最新版。ここは適宜バージョンを変えてください。
git clone https://github.com/asdf-vm/asdf.git ~/.asdf --branch v0.16.7 
echo 'export PATH="${ASDF_DATA_DIR:-$HOME/.asdf}/shims:$PATH"' >> ~/.bashrc
source ~/.bashrc

4. asdfからPython3.13系を導入

最後にasdf経由でPython3.13をインストールしました。

asdf plugin add python
asdf install python 3.13.2
asdf local python 3.13.2
python --version
# => Python 3.13.2

無事Windows環境で、asdf経由でPython3.13を導入することができました!

最後に

これまでは、Macのbrewコマンドで一発で行けていたので悲しみ・・・。

brew install asdf
asdf plugin add python
asdf install python 3.13.2
asdf local python 3.13.2
2
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
2
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?