Red Hat Enterprise Linux 6.2でPython 2.6の代わりにPython 2.7をデフォルトとして使用するには?私はまだ2.6が表示されますか?

Red Hat Enterprise Linux 6.2でPython 2.6の代わりにPython 2.7をデフォルトとして使用するには?私はまだ2.6が表示されますか?

RHEL 6.2 Python 2.6がありますが、パッケージ化されyumたデフォルトのPython 2.7を使用する必要があります。したがって、作業量が多いシステムなので問題にならず、問題なくPython 2.7だけが必要です。

次の操作を行いましたが、まだpythonバージョンが2.6として表示されます。これについてのアドバイスはありますか?

$ cat /etc/issue
Red Hat Enterprise Linux Server release 6.2 (Santiago)
Kernel \r on an \m

$ python --version
Python 2.6.6

$ sudo sh -c 'wget -qO- http://people.redhat.com/bkabrda/scl_python27.repo >> /etc/yum.repos.d/scl.repo'

$ yum search python27
Loaded plugins: amazon-id, rhui-lb, security
scl_python27                                                                                                                                      | 2.9 kB     00:00     
scl_python27/primary_db                                                                                                                           |  38 kB     00:00     
========================================================================= N/S Matched: python27 =========================================================================
python27.i686 : Package that installs python27
python27.x86_64 : Package that installs python27
python27-expat-debuginfo.i686 : Debug information for package python27-expat
python27-expat-debuginfo.x86_64 : Debug information for package python27-expat
python27-python-coverage-debuginfo.i686 : Debug information for package python27-python-coverage
python27-python-coverage-debuginfo.x86_64 : Debug information for package python27-python-coverage
python27-python-debuginfo.i686 : Debug information for package python27-python
python27-python-debuginfo.x86_64 : Debug information for package python27-python
python27-python-markupsafe-debuginfo.i686 : Debug information for package python27-python-markupsafe
python27-python-markupsafe-debuginfo.x86_64 : Debug information for package python27-python-markupsafe
python27-python-simplejson-debuginfo.i686 : Debug information for package python27-python-simplejson
python27-python-simplejson-debuginfo.x86_64 : Debug information for package python27-python-simplejson
python27-python-sqlalchemy-debuginfo.i686 : Debug information for package python27-python-sqlalchemy
python27-python-sqlalchemy-debuginfo.x86_64 : Debug information for package python27-python-sqlalchemy
python27-runtime.i686 : Package that handles python27 Software Collection.
python27-runtime.x86_64 : Package that handles python27 Software Collection.
python27-babel.noarch : Tools for internationalizing Python applications
python27-build.i686 : Package shipping basic build configuration
python27-build.x86_64 : Package shipping basic build configuration
python27-expat.i686 : An XML parser library
python27-expat.x86_64 : An XML parser library
python27-expat-devel.i686 : Libraries and header files to develop applications using expat
python27-expat-devel.x86_64 : Libraries and header files to develop applications using expat
python27-expat-static.i686 : expat XML parser static library
python27-expat-static.x86_64 : expat XML parser static library
python27-python.i686 : An interpreted, interactive, object-oriented programming language
python27-python.x86_64 : An interpreted, interactive, object-oriented programming language
python27-python-babel.noarch : Library for internationalizing Python applications
python27-python-coverage.i686 : Code coverage testing module for Python
python27-python-coverage.x86_64 : Code coverage testing module for Python
python27-python-debug.i686 : Debug version of the Python runtime
python27-python-debug.x86_64 : Debug version of the Python runtime
python27-python-devel.i686 : The libraries and header files needed for Python development
python27-python-devel.x86_64 : The libraries and header files needed for Python development
python27-python-docutils.noarch : System for processing plaintext documentation
python27-python-jinja2.noarch : General purpose template engine
python27-python-libs.i686 : Runtime libraries for Python
python27-python-libs.x86_64 : Runtime libraries for Python
python27-python-markupsafe.i686 : Implements a XML/HTML/XHTML Markup safe string for Python
python27-python-markupsafe.x86_64 : Implements a XML/HTML/XHTML Markup safe string for Python
python27-python-nose.noarch : Discovery-based unittest extension for Python
python27-python-nose-docs.noarch : Nose Documentation
python27-python-pygments.noarch : Syntax highlighting engine written in Python
python27-python-setuptools.noarch : Easily build and distribute Python packages
python27-python-simplejson.i686 : Simple, fast, extensible JSON encoder/decoder for Python
python27-python-simplejson.x86_64 : Simple, fast, extensible JSON encoder/decoder for Python
python27-python-sphinx.noarch : Python documentation generator
python27-python-sphinx-doc.noarch : Documentation for python-sphinx
python27-python-sqlalchemy.i686 : Modular and flexible ORM library for python
python27-python-sqlalchemy.x86_64 : Modular and flexible ORM library for python
python27-python-test.i686 : The test modules from the main python package
python27-python-test.x86_64 : The test modules from the main python package
python27-python-tools.i686 : A collection of development tools included with Python
python27-python-tools.x86_64 : A collection of development tools included with Python
python27-python-virtualenv.noarch : Tool to create isolated Python environments
python27-python-werkzeug.noarch : The Swiss Army knife of Python web development
python27-python-werkzeug-doc.noarch : Documentation for python-werkzeug
python27-tkinter.i686 : A graphical user interface for the Python scripting language
python27-tkinter.x86_64 : A graphical user interface for the Python scripting language

編集する:(私は次の選択肢も試しました):

#!/bin/bash
# Install Python 2.7.3 alternatively
yum groupinstall "development tools" -y
yum install readline-devel openssl-devel gmp-devel ncurses-devel gdbm-devel zlib-devel expat-devel libGL-devel tk tix gcc-c++ libX11-devel glibc-devel bzip2 tar tcl-devel tk-devel pkgconfig tix-devel bzip2-devel sqlite-devel autoconf db4-devel libffi-devel valgrind-devel -y

mkdir tmp
cd tmp
wget http://python.org/ftp/python/2.7.3/Python-2.7.3.tgz
tar xvfz Python-2.7.3.tgz
cd Python-2.7.3
./configure --prefix=/opt/python2.7 --enable-shared
make
make altinstall
echo "/opt/python2.7/lib" >> /etc/ld.so.conf.d/opt-python2.7.conf
ldconfig
cd ..
cd ..
rm -rf tmp


[root@ip-10-59-143-73 bin]# pwd
/opt/python2.7/bin
[root@ip-10-59-143-73 bin]# tree
.
├── 2to3
├── idle
├── pydoc
├── python2.7
├── python2.7-config
└── smtpd.py

0 directories, 6 files
[root@ip-10-59-143-73 bin]# ./python2.7 --version
Python 2.7.3

[root@ip-10-59-143-73 bin]# python --version
Python 2.6.6

ベストアンサー1

システムレベルのPythonを使用する代わりに、次のようなものを使用することをお勧めします。virtualenv~とvirtualenvwrapper。これら2つのツールを一緒に使用することで、Pythonのシステムレベルのインストールを必要なシステムレベルのソフトウェアに対して定常状態に保つことなく、Python +ライブラリのローカルコピーを非常に簡単に設定できます。

仮想環境

virtualenvは、孤立したPython環境を作成するためのツールです。

独自のインストールディレクトリを持つ環境を作成し、他のvirtualenv環境とライブラリを共有しません(そしてオプションでグローバルにインストールされたライブラリにアクセスしません)。

仮想環境ラッパー

virtualenvwrapper は、Ian Bicking の virtualenv ツールの拡張セットです。この拡張には、仮想環境を作成および削除し、開発ワークフローを管理するためのラッパーが含まれているため、依存関係に矛盾を起こすことなく複数のプロジェクトで同時に作業することが容易になります。

現在、ほとんどの言語はこのタイプのツールを提供します。この問題に関する次のタイトルの私の投稿をご覧ください。統計に推奨されるLinuxディストリビューションは何ですか?他の言語でも同様です。

おすすめ記事