📘
pyenvを使ってpythonをインストールするときに出たエラー達
pyenv
UbuntuへのPythonのインストールはちと面倒なので、pyenvを使うのが楽だと思う。
導入などは次の記事を参考にしていただきたい。
エラー
Cコンパイラないぜ!!
エラーログ
$ pyenv install 3.10.6
Downloading Python-3.10.6.tar.xz...
-> https://www.python.org/ftp/python/3.10.6/Python-3.10.6.tar.xz
Installing Python-3.10.6...
BUILD FAILED (Ubuntu 22.04 using python-build 2.3.36-16-g21c2a3dd)
Inspect or clean up the working tree at /tmp/python-build.20240305054150.35640
Results logged to /tmp/python-build.20240305054150.35640.log
Last 10 log lines:
checking for python3.10... python3.10
checking for --enable-universalsdk... no
checking for --with-universal-archs... no
checking MACHDEP... "linux"
checking for gcc... no
checking for cc... no
checking for cl.exe... no
configure: error: in `/tmp/python-build.20240305054150.35640/Python-3.10.6':
configure: error: no acceptable C compiler found in $PATH
See `config.log' for more details
Cコンパイラが見つからないって言われました。別途インストール必要だったんですね。
なので次のコマンドでインストールしてあげましょう。
sudo apt install build-essential
いくつかのライブラリが見つからないぜ!!
エラーログ
pyenv install 3.10.6
Downloading Python-3.10.6.tar.xz...
-> https://www.python.org/ftp/python/3.10.6/Python-3.10.6.tar.xz
Installing Python-3.10.6...
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/home/main/.pyenv/versions/3.10.6/lib/python3.10/bz2.py", line 17, in <module>
from _bz2 import BZ2Compressor, BZ2Decompressor
ModuleNotFoundError: No module named '_bz2'
WARNING: The Python bz2 extension was not compiled. Missing the bzip2 lib?
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/home/main/.pyenv/versions/3.10.6/lib/python3.10/curses/__init__.py", line 13, in <module>
from _curses import *
ModuleNotFoundError: No module named '_curses'
WARNING: The Python curses extension was not compiled. Missing the ncurses lib?
Traceback (most recent call last):
File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'readline'
WARNING: The Python readline extension was not compiled. Missing the GNU readline lib?
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/home/main/.pyenv/versions/3.10.6/lib/python3.10/sqlite3/__init__.py", line 57, in <module>
from sqlite3.dbapi2 import *
File "/home/main/.pyenv/versions/3.10.6/lib/python3.10/sqlite3/dbapi2.py", line 27, in <module>
from _sqlite3 import *
ModuleNotFoundError: No module named '_sqlite3'
WARNING: The Python sqlite3 extension was not compiled. Missing the SQLite3 lib?
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/home/main/.pyenv/versions/3.10.6/lib/python3.10/lzma.py", line 27, in <module>
from _lzma import *
ModuleNotFoundError: No module named '_lzma'
WARNING: The Python lzma extension was not compiled. Missing the lzma lib?
Installed Python-3.10.6 to /home/main/.pyenv/versions/3.10.6
インストール自体はできましたが、正常に動かなかった。
いくつかのライブラリがないそうなので、インストールしてあげましょう。
sudo apt-get install libbz2-dev
sudo apt-get install libncurses5-dev
sudo apt-get install libreadline-dev
sudo apt-get install sqlite3 libsqlite3-dev
sudo apt-get install liblzma-dev
以上
以上です。
Discussion