alma linuxでpython3.9を使う
CentOSの代替OSとして注目されているOSの一つにAlma Linux(アルマリナックス)があります。今回はこのOSにpython3系をインストールしたいと思います
テスト環境
- ホストOS:Windows10
- ゲストOS:Alma Linux
- 仮想環境:vagrant+virtualBox
- インストール:python3.9
モジュールコマンドからインストール
CentOS8から新たに追加された機能にモジュールというのがあります。このモジュールから色々インストールできます。今回はここからpython3.9をインストールしてみたいと思います
リストで確認すると色々ある
</p> <h1>確認</h1> <p>sudo dnf module list</p> <p>Name Stream Profiles Summary 389-ds 1.4 389 Directory Server (base) ant 1.10 [d] common [ Java build tool d] container-tools rhel8 [d] common [ Most recent (rolling) versions of podman, buildah, skopeo, runc, conmon, runc, conmon, CRIU, Udica, etc as well as dependencies such as container-selinux built and tested together, and update d] d as frequently as every 12 weeks. container-tools 1.0 common [ Stable versions of podman 1.0, buildah 1.5, skopeo 0.1, runc, conmon, CRIU, Udica, etc as well as dependencies such as container-selinux built and tested together, and supported for 24 months d] . container-tools 2.0 common [ Stable versions of podman 1.6, buildah 1.11, skopeo 0.1, runc, conmon, etc as well as dependencies such as container-selinux built and tested together, and supported as documented on the Appl d] ication Stream lifecycle page. container-tools 3.0 common [ Stable versions of podman 3.0, buildah 1.19, skopeo 1.2, runc, conmon, etc as well as dependencies such as container-selinux built and tested together, and supported as documented on the Appl d] ication Stream lifecycle page. eclipse rhel8 java [d] An open, extensible IDE and application platform freeradius 3.0 [d] server [ High-performance and highly configurable free RADIUS server d] gimp 2.8 [d] common [ gimp module d], deve l go-toolset rhel8 [d] common [ Go d] httpd 2.4 [d] common [ Apache HTTP Server d], deve l, minim al idm DL1 adtrust, The Red Hat Enterprise Linux Identity Management system module client, common [d], dns , server idm client [d] common [ RHEL IdM long term support client module d] inkscape 0.92.3 [d] common [ Vector-based drawing program using SVG d] javapackages-runtime 201801 [d] common [ Basic runtime utilities to support Java applications d] jmc rhel8 [d] common [ Java Mission Control is a profiling and diagnostics tool for the Hotspot JVM d], core libselinux-python 2.8 common Python 2 bindings for libselinux llvm-toolset rhel8 [d] common [ LLVM d] mailman 2.1 [d] common [ Electronic mail discussion and e-newsletter lists managing software d] mariadb 10.3 [d] client, MariaDB Module galera, server [ d] mariadb 10.5 client, MariaDB Module galera, server [ d] maven 3.5 [d] common [ Java project management and project comprehension tool d] maven 3.6 common [ Java project management and project comprehension tool d] mercurial 4.8 [d] common [ Mercurial -- a distributed SCM d] mod_auth_openidc 2.3 Apache module suporting OpenID Connect authentication mysql 8.0 [d] client, MySQL Module server [ d] nginx 1.14 [d] common [ nginx webserver d] nginx 1.16 common [ nginx webserver d] nginx 1.18 common [ nginx webserver d] nodejs 10 [d] common [ Javascript runtime d], deve lopment, minimal , s2i nodejs 12 common [ Javascript runtime d], deve lopment, minimal , s2i nodejs 14 common [ Javascript runtime d], deve lopment, minimal , s2i parfait 0.5 common Parfait Module perl 5.24 common [ Practical Extraction and Report Language d], mini mal perl 5.26 [d][e] common [ Practical Extraction and Report Language d], mini mal perl 5.30 common [ Practical Extraction and Report Language d], mini mal perl-App-cpanminus 1.7044 [d] common [ Get, unpack, build and install CPAN modules d] perl-DBD-MySQL 4.046 [d] common [ A MySQL interface for Perl d] perl-DBD-Pg 3.7 [d] common [ A PostgreSQL interface for Perl d] perl-DBD-SQLite 1.58 [d] common [ SQLite DBI driver d] perl-DBI 1.641 [d] common [ A database access API for Perl d] perl-FCGI 0.78 [d] common [ FastCGI Perl bindings d] perl-IO-Socket-SSL 2.066 [d][e] common [ Perl library for transparent TLS d] perl-YAML 1.24 [d] common [ Perl parser for YAML d] perl-libwww-perl 6.34 [d][e] common [ A Perl interface to the World-Wide Web d] php 7.2 [d] common [ PHP scripting language d], deve l, minim al php 7.3 common [ PHP scripting language d], deve l, minim al php 7.4 common [ PHP scripting language d], deve l, minim al pki-core 10.6 PKI Core module for PKI 10.6 or later pki-deps 10.6 PKI Dependencies module for PKI 10.6 or later pmdk 1_fileformat_v6 Persistent Memory Development Kit (former NVML) postgresql 9.6 client, PostgreSQL server and client module server [ d] postgresql 10 [d] client, PostgreSQL server and client module server [ d] postgresql 12 client, PostgreSQL server and client module server [ d] postgresql 13 client, PostgreSQL server and client module server [ d] python27 2.7 [d] common [ Python programming language, version 2.7 d] python36 3.6 [d] build, c Python programming language, version 3.6 ommon [d ] python38 3.8 [d] build, c Python programming language, version 3.8 ommon [d ] python39 3.9 [d] build, c Python programming language, version 3.9 ommon [d ] redis 5 [d] common [ Redis persistent key-value database d] redis 6 common [ Redis persistent key-value database d] rhn-tools 1.0 [d] common [ Red Hat Satellite 5 tools for RHEL d] ruby 2.5 [d] common [ An interpreter of object-oriented scripting language d] ruby 2.6 common [ An interpreter of object-oriented scripting language d] ruby 2.7 common [ An interpreter of object-oriented scripting language d] rust-toolset rhel8 [d] common [ Rust d] satellite-5-client 1.0 [d][e] common [ Red Hat Satellite 5 client packages d], gui scala 2.10 [d] common [ A hybrid functional/object-oriented language for the JVM d] squid 4 [d] common [ Squid - Optimising Web Delivery d] subversion 1.10 [d] common [ Apache Subversion d], serv er subversion 1.14 common [ Apache Subversion d], serv er swig 3.0 [d] common [ Connects C/C++/Objective C to some high-level programming languages d], comp lete swig 4.0 common [ Connects C/C++/Objective C to some high-level programming languages d], comp lete varnish 6 [d] common [ Varnish HTTP cache d] virt rhel [d] common [ Virtualization module d]
実際にコマンドでみていると色々あるなーとわかります。PHPも7.4系がいますね。
python3.9をインストール
実際にインストールしていきます。rootでもよいですが、今回はsudo権限のあるvagrantユーザーで行います
sudo dnf module install -y python39</p> <h1>Last metadata expiration check: 0:07:38 ago on Thu 24 Jun 2021 12:18:15 PM UTC. Dependencies resolved.</h1> <h1>Package Architecture Version Repository Size</h1> <p>Installing group/module packages: python39 x86_64 3.9.2-1.module_el8.4.0+2374+27ce8e03 appstream 31 k Installing dependencies: python39-libs x86_64 3.9.2-1.module_el8.4.0+2374+27ce8e03 appstream 8.1 M python39-pip-wheel noarch 20.2.4-3.module_el8.4.0+2374+27ce8e03 appstream 1.3 M python39-setuptools-wheel noarch 50.3.2-3.module_el8.4.0+2374+27ce8e03 appstream 496 k Installing weak dependencies: python39-pip noarch 20.2.4-3.module_el8.4.0+2374+27ce8e03 appstream 2.0 M python39-setuptools noarch 50.3.2-3.module_el8.4.0+2374+27ce8e03 appstream 870 k Installing module profiles: python39/common Enabling module streams: python39 3.9</p> <h1>Transaction Summary</h1> <p>Install 6 Packages</p> <p>Total download size: 13 M Installed size: 45 M Downloading Packages:
インストール確認
インストールできたか確認します
[vagrant@localhost ~]$ python --version -bash: python: command not found</p> <p>[vagrant@localhost ~]$ python3 --version Python 3.9.2
ファイルを作って確認してみる
簡単なサンプルファイルを作ってみます
[vagrant@localhost ~]$ vi sample.py print ("こんにちは世界!")</p> <p>[vagrant@localhost ~]$ python3 sample.py こんにちは世界!</p> <p>[vagrant@localhost ~]$ python sample.py -bash: python: command not found
python3といれると問題なく実行できますが、pythonだと実行できません。できればpythonコマンドでも実行できるようにしたいです
シンボリックリンクを貼る
pythonといれても実行できるようにしていきます
</p> <h1>python関連ファイルを検索</h1> <p>[vagrant@localhost ~]$ whereis python python: /usr/bin/python3.9 /usr/lib/python3.6 /usr/lib/python3.9 /usr/lib64/python3.6 /usr/lib64/python3.9 /usr/include/python3.6m /usr/include/python3.9 /usr/share/man/man1/python.1.gz
</p> <h1>シンボリックリンクを作成</h1> <p>sudo ln -s /usr/bin/python3.9 /usr/bin/python
</p> <h1>バージョンの表示</h1> <p>[vagrant@localhost ~]$ python3 -V Python 3.9.2
無事にできました。pipも同じようにします
</p> <h1>python関連ファイルを検索</h1> <p>[vagrant@localhost ~]$ whereis pip pip: /usr/bin/pip3.9
</p> <h1>シンボリックリンクを作成</h1> <p>[vagrant@localhost ~]$ sudo ln -s /usr/bin/pip3.9 /usr/bin/pip
</p> <h1>バージョンの表示</h1> <p>[vagrant@localhost ~]$ pip -V pip 20.2.4 from /usr/lib/python3.9/site-packages/pip (python 3.9)
問題なくできました
YouTube動画
設定動画になります
個人支援・寄付について
サイトラボでは個人支援・寄付を受けております。ご協力いただける方はお願いいたします。当サイトではビットコインで受け付けております。
- ビットコイン:3LHnADwZwUbic2L45EnVJEykiG6KfbqrwS