Python 2.6.6 Python 2.75.15にアップグレードする詳細手順
3685 ワード
最近はPythonを使ってMySQLデータベースに関する問題を処理する際に、Python 2.75および以上のバージョンを使用する必要がありますが、centos 6.5などのバージョンのオペレーティングシステムはデフォルトでは自分のバージョンが2.6.6であるため、pythonをアップグレードする必要があります。
Pythonアップグレードのステップは、大きく分けて次のステップに分けられます。依存パッケージ をインストールします。インストールパッケージをダウンロードしてオペレーティングシステムにアップロードします。 解凍、コンパイル、インストール は、関連する経路の下のpythonコマンド を構成する。 yum起動経路を変更する 1.依存パッケージのインストール
铉コンパイルはgccを使用する必要がありますので、gccを確認してインストールしてください。
は今回wgetを採用して直接linuxシステムでダウンロードします。ダウンロード経路はpython公式サイトhttps://www.python.org/ftp/pythonです。対応するバージョンを選択してダウンロードします。
同前


4.関連経路のpythonコマンドを設定します。
皱python命令を確認する
コピー命令、配置ソフトリンクを修正して、python 2.6バージョンの命令を削除できないように注意してください。yumはpython 2.7をサポートしていないので、yumコマンドを修正する時はpython 2.6を使用する必要があります。
5.yum起動経路を変更する
yumはPython 2.7に対応していません。Python 2.6をPython 2.7にアップグレードした後、yumは正常に動作できなくなります。したがって、yumのPythonバージョンを指定する必要があります。
xiアップグレード後にyum命令を実行してエラーメッセージを送ります。
The re was a problem importing one of the Python modules
required to run yum.The error leading to this problem was:
No module named yum
Please install a package which provides this module,or
verify that the module is installed corectly.
It's possible that the above module doesn't match the
current version of Python、which is:
2.2.7.15(default、Jun 25 2018、09:22:50)
[GCC 4.4.4.7 20333(Red Hat 4.4.4.4.7-18)]
If you cannot solove this problem yourself,please go to
the yum faq at:
http://yum.baseurl.org/wiki/Faq

改訂yum起動命令
ハ改定後のテストは、下記の通り修正されました。yumは正常に動作するようになりました。

これでpython 2.6にアップグレードしてpython 2.75.15の仕事に完成しました。python命令を実行するとpython 2.75のバージョンを実行するPythonに相当します。python 2.6を実行します。python 2.6のpythonを使用します。以下の通りです。

ここでPython 2.6からPython 2.75.15にアップグレードする過程について詳細な文章を紹介します。Python 2.6からPython 2.75にアップグレードしました。以前の記事を検索してください。または下記の関連記事を引き続きご覧ください。これからもよろしくお願いします。
Pythonアップグレードのステップは、大きく分けて次のステップに分けられます。
铉コンパイルはgccを使用する必要がありますので、gccを確認してインストールしてください。
yum install gcc -y
2.インストールパッケージをダウンロードしてオペレーティングシステムにアップロードするは今回wgetを採用して直接linuxシステムでダウンロードします。ダウンロード経路はpython公式サイトhttps://www.python.org/ftp/pythonです。対応するバージョンを選択してダウンロードします。
wget https://www.python.org/ftp/python/2.7.15/Python-2.7.15.tgz
3.解凍、コンパイル、取り付け同前
tar -zxvf Python-2.7.15.tgz
葃コンパイル、取り付け
cd Python-2.7.15
./configure --prefix=/usr/local/python2.7
エラーがないかチェックして、エラーがない場合は続行します。
make
make install
取り付け結果を確認する
cd /usr/local/python2.7/bin
ll
./python2 # python2, ,
./python2.7 # python2, ,

4.関連経路のpythonコマンドを設定します。
皱python命令を確認する
whereis python

コピー命令、配置ソフトリンクを修正して、python 2.6バージョンの命令を削除できないように注意してください。yumはpython 2.7をサポートしていないので、yumコマンドを修正する時はpython 2.6を使用する必要があります。
cd /usr/bin
ll *python*
unlink python
unlink python2
ll *python*
cp /usr/local/python2.7/bin/python2.7 /usr/bin/python2.7 #
ln -s /usr/bin/python2.7 python
ln -s python python2
ll *python* python # Python2.7.15, ,

5.yum起動経路を変更する
yumはPython 2.7に対応していません。Python 2.6をPython 2.7にアップグレードした後、yumは正常に動作できなくなります。したがって、yumのPythonバージョンを指定する必要があります。
xiアップグレード後にyum命令を実行してエラーメッセージを送ります。
The re was a problem importing one of the Python modules
required to run yum.The error leading to this problem was:
No module named yum
Please install a package which provides this module,or
verify that the module is installed corectly.
It's possible that the above module doesn't match the
current version of Python、which is:
2.2.7.15(default、Jun 25 2018、09:22:50)
[GCC 4.4.4.7 20333(Red Hat 4.4.4.4.7-18)]
If you cannot solove this problem yourself,please go to
the yum faq at:
http://yum.baseurl.org/wiki/Faq

改訂yum起動命令
vim /usr/bin/yum # #!/usr/bin/python #!/usr/bin/python2.6

ハ改定後のテストは、下記の通り修正されました。yumは正常に動作するようになりました。

これでpython 2.6にアップグレードしてpython 2.75.15の仕事に完成しました。python命令を実行するとpython 2.75のバージョンを実行するPythonに相当します。python 2.6を実行します。python 2.6のpythonを使用します。以下の通りです。

ここでPython 2.6からPython 2.75.15にアップグレードする過程について詳細な文章を紹介します。Python 2.6からPython 2.75にアップグレードしました。以前の記事を検索してください。または下記の関連記事を引き続きご覧ください。これからもよろしくお願いします。