最新のPythonをインストールしたいのですが、この投稿の時点では3.6です。しかし、リポジトリではPython 3.4.2が最新バージョンとなっています。
私は試しました。
$ sudo apt-get update
$ sudo apt-get install python3
python3 is already the newest version.
$ python -V
Python 3.4.2
私のWindowsワークステーションでPython 3.6にアップグレードするには、単にexeをダウンロードして、"next"を数回クリックするだけで完了しました。Debian JessieにPython 3.6をインストールするには、どのような手順が適切で公式に認められていますか?
Debian 8にPython-3.6
をインストールするには次のようにします。
wget https://www.python.org/ftp/python/3.6.9/Python-3.6.9.tgz
tar xvf Python-3.6.9.tgz
cd Python-3.6.9
./configure --enable-optimizations --enable-shared
make -j8
sudo make altinstall
python3.6
公式サイト]1によると,make altinstall
を使うことが推奨されています.
また,pip
を含めたい場合には,configureコールに--with-ensurepip=install
を追加する必要があります.詳細は ./configure --help
を参照してください。
Warning:
make install
は python バイナリを上書きしたり、偽装したりすることがあります。そのため、make install
の代わりにmake altinstall
を推奨します。make altinstall
はexec_prefix/bin/pythonversion
のみをインストールします。
いくつかのパッケージは、いくつかの既知の問題を避けるためにインストールする必要があります。[一般的なビルドの問題]2
Ubuntu/Debian:
sudo apt-get install -y make build-essential libssl-dev zlib1g-dev libbz2-dev \
libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev libncursesw5-dev \
xz-utils tk-dev libffi-dev liblzma-dev
libreadline-devの代替品です。
sudo apt install libedit-dev
Fedora/CentOS/RHEL(aws ec2)に対応しました。
sudo yum install zlib-devel bzip2 bzip2-devel readline-devel sqlite sqlite-devel \
openssl-devel xz xz-devel libffi-devel
openssl-develの代替品です。
sudo yum install compat-openssl10-devel --allowerasing
**アップデート
最新の python-x.y.z.tar.gz
は こちら からダウンロードできます。
デフォルトのpythonバージョンを設定したり、簡単に切り替えたりするには、update-alternatives
を複数のpythonバージョンで更新する必要があります。
例えば、debian stretchにpython3.7をインストールしたとすると、whereis python
コマンドでバイナリ(*/bin/python
)の場所を確認します。
/usr/local/bin/python3.7
/usr/bin/python2.7
/usr/bin/python3.5
pythonのバージョンを追加します。
update-alternatives --install /usr/bin/python python /usr/local/bin/python3.7 50
update-alternatives --install /usr/bin/python python /usr/bin/python2.7 40
update-alternatives --install /usr/bin/python python /usr/bin/python3.5 30
50の優先度を持つ
python3.7がデフォルトの python になり、
python -V` が表示されます。
Python 3.7.0b2
これらを切り替えるには、次のようにします。
update-alternatives --config python
サンプル出力です。
There are 3 choices for the alternative python (providing /usr/bin/python).
Selection Path Priority Status
------------------------------------------------------------
* 0 /usr/local/bin/python3.7 50 auto mode
1 /usr/bin/python2.7 40 manual mode
2 /usr/bin/python3.5 30 manual mode
3 /usr/local/bin/python3.7 50 manual mode
Press <enter> to keep the current choice[*], or type selection number:
[2]: https://github.com/pyenv/pyenv/wiki/Common-build-problems [3]: https://stackoverflow.com/questions/41489439/pip3-installs-inside-virtual-environment-with-python3-6-failing-due-to-ssl-modul/41601137#41601137
pyenv
: https://github.com/yyuu/pyenv を見てみるといいでしょう。Amaral Lab.の pyenv
チュートリアルからの引用です。
以前は Pythonbrew として知られていた pyenv は、Python のグローバルバージョンの変更、複数の Python バージョンのインストール、ディレクトリの設定などを行うことができます。 Pythonバージョンの変更、複数のPythonバージョンのインストール、ディレクトリの設定などができます。 pyenvは、グローバルなPythonバージョンの変更、複数のPythonバージョンのインストール、ディレクトリ(プロジェクト)ごとのPythonバージョンの設定、仮想Python環境(> python environment)の作成/管理を行うことができます。 pyenvは、グローバルなPythonバージョンを変更したり、複数のPythonバージョンをインストールしたり、ディレクトリ(プロジェクト)ごとのPythonバージョンを設定したり、仮想的なPython環境("virtualenvs")を作成/管理したりします。これらの作業はすべて、NIXスタイルの Python自体に依存することなく、NIXスタイルのマシン(LinuxおよびOS X)上で行われます。 また、ユーザーレベルでも動作し、sudoコマンドも必要ありません。
Debian は Python 3.6 をリポジトリに持っていません。ここに現在の Python3 の状況のスナップショットがあります。
wheezy (oldstable) (python): interactive high-level object-oriented language (default python3 version)
3.2.3-6: all
jessie (stable) (python): interactive high-level object-oriented language (default python3 version)
3.4.2-2: amd64 arm64 armel armhf i386 mips mipsel powerpc ppc64el s390x
stretch (testing) (python): interactive high-level object-oriented language (default python3 version)
3.5.1-4: amd64 arm64 armel armhf i386 mips mips64el mipsel ppc64el s390x
sid (unstable) (python): interactive high-level object-oriented language (default python3 version)
3.5.1-4: alpha amd64 arm64 armel armhf hppa hurd-i386 i386 kfreebsd-amd64 kfreebsd-i386 m68k mips mips64el mipsel powerpc powerpcspe ppc64 ppc64el s390x sh4 sparc64 x32
これらは こちらで確認できます。
3.6をインストールするには、ソースからインストールするか、Linuxbrewのようなものを使ってホームディレクトリにインストールします。