😥
Lubuntu22.04+brewのasdfでpythonをインストールできない
私の環境
- Lubuntu 22.04
- asdf v0.14.1 (brewでインストール)
asdfでpythonをインストールできない
asdfでpythonをインストールしようとしたところ、下記のようなエラーになりました。
$ asdf install python 3.11.10
python-build 3.11.10 /home/blue21/.asdf/installs/python/3.11.10
Downloading Python-3.11.10.tar.xz...
-> https://www.python.org/ftp/python/3.11.10/Python-3.11.10.tar.xz
Installing Python-3.11.10...
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/home/blue21/.asdf/installs/python/3.11.10/lib/python3.11/ssl.py", line 100, in <module>
import _ssl # if we can't import it, let the error propagate
^^^^^^^^^^^
ModuleNotFoundError: No module named '_ssl'
ERROR: The Python ssl extension was not compiled. Missing the OpenSSL lib?
Please consult to the Wiki page to fix the problem.
https://github.com/pyenv/pyenv/wiki/Common-build-problems
BUILD FAILED (Ubuntu 22.04 using python-build 2.4.19-2-g61406193)
Inspect or clean up the working tree at /tmp/python-build.20241201134034.41996
Results logged to /tmp/python-build.20241201134034.41996.log
Last 10 log lines:
LD_LIBRARY_PATH=/tmp/python-build.20241201134034.41996/Python-3.11.10 ./python -E -m ensurepip \
$ensurepip --root=/ ; \
fi
Looking in links: /tmp/tmppqq1jrkr
Processing /tmp/tmppqq1jrkr/setuptools-65.5.0-py3-none-any.whl
Processing /tmp/tmppqq1jrkr/pip-24.0-py3-none-any.whl
Installing collected packages: setuptools, pip
WARNING: The scripts pip3 and pip3.11 are installed in '/home/blue21/.asdf/installs/python/3.11.10/bin' which is not on PATH.
Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
Successfully installed pip-24.0 setuptools-65.5.0
解決方法
下記のコマンドを実行して、pythonをインストールできました。brewの状態によってgccのバージョンは違う可能性があります。
brew install openssl readline sqlite3 xz zlib tcl-tk
export CC=/home/linuxbrew/.linuxbrew/bin/gcc-14
export LDFLAGS="-L$(brew --prefix)/lib"
export CPPFLAGS="-I$(brew --prefix)/include"
export PKG_CONFIG_PATH="$(brew --prefix)/lib/pkgconfig"
asdf install python 3.11.10
以下は、インストールコマンドの結果です。なんか色々メッセージが出てますが、インストールは成功しました。
python-build 3.11.10 /home/blue21/.asdf/installs/python/3.11.10
Downloading Python-3.11.10.tar.xz...
-> https://www.python.org/ftp/python/3.11.10/Python-3.11.10.tar.xz
Installing Python-3.11.10...
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/home/blue21/.asdf/installs/python/3.11.10/lib/python3.11/tkinter/__init__.py", line 38, in <module>
import _tkinter # If this fails your Python may not be configured for Tk
^^^^^^^^^^^^^^^
ModuleNotFoundError: No module named '_tkinter'
WARNING: The Python tkinter extension was not compiled and GUI subsystem has been detected. Missing the Tk toolkit?
Installed Python-3.11.10 to /home/blue21/.asdf/installs/python/3.11.10
asdfでpythonを確認した結果です。
$ asdf list python
3.11.10
3.11.9
*3.12.3
3.8.18
Discussion