{"id":200,"date":"2021-10-19T12:25:06","date_gmt":"2021-10-19T04:25:06","guid":{"rendered":"http:\/\/47.98.165.52\/?p=200"},"modified":"2022-01-28T16:54:16","modified_gmt":"2022-01-28T08:54:16","slug":"centos7%e5%ae%89%e8%a3%85python","status":"publish","type":"post","link":"\/?p=200","title":{"rendered":"CentOS7\u5b89\u88c5python"},"content":{"rendered":"<h2>\u4e0b\u8f7d\u5b89\u88c5\u4f9d\u8d56\u5305<\/h2>\n<pre><code class=\"language-shell\">yum install openssl-devel bzip2-devel expat-devel gdbm-devel readline-devel sqlite-devel gcc gcc-c++ openssl-devel libffi-devel python-devel mariadb-devel<\/code><\/pre>\n<h2>\u4e0b\u8f7d\u5b89\u88c5\u5305<\/h2>\n<pre><code class=\"language-shell\">wget https:\/\/www.python.org\/ftp\/python\/3.7.2\/Python-3.7.2.tar.xz<\/code><\/pre>\n<h2>\u89e3\u538b<\/h2>\n<pre><code class=\"language-shell\">tar -xvJf  Python-3.7.2.tar.xz<\/code><\/pre>\n<h2>\u521b\u5efa\u7f16\u8bd1\u5b89\u88c5\u76ee\u5f55<\/h2>\n<pre><code class=\"language-shell\">mkdir \/usr\/local\/python3 <\/code><\/pre>\n<h2>\u5b89\u88c5<\/h2>\n<pre><code class=\"language-shell\">cd Python-3.7.2\n.\/configure --prefix=\/usr\/local\/python3 --enable-optimizations --with-ssl \n#\u7b2c\u4e00\u4e2a\u6307\u5b9a\u5b89\u88c5\u7684\u8def\u5f84,\u4e0d\u6307\u5b9a\u7684\u8bdd,\u5b89\u88c5\u8fc7\u7a0b\u4e2d\u53ef\u80fd\u8f6f\u4ef6\u6240\u9700\u8981\u7684\u6587\u4ef6\u590d\u5236\u5230\u5176\u4ed6\u4e0d\u540c\u76ee\u5f55,\u5220\u9664\u8f6f\u4ef6\u5f88\u4e0d\u65b9\u4fbf,\u590d\u5236\u8f6f\u4ef6\u4e5f\u4e0d\u65b9\u4fbf.\n#\u7b2c\u4e8c\u4e2a\u53ef\u4ee5\u63d0\u9ad8python10%-20%\u4ee3\u7801\u8fd0\u884c\u901f\u5ea6.\n#\u7b2c\u4e09\u4e2a\u662f\u4e3a\u4e86\u5b89\u88c5pip\u9700\u8981\u7528\u5230ssl,\u540e\u9762\u62a5\u9519\u4f1a\u6709\u63d0\u5230.\nmake &amp;&amp; make install<\/code><\/pre>\n<h2>\u521b\u5efa\u8f6f\u94fe\u63a5<\/h2>\n<pre><code class=\"language-shell\">ln -s \/usr\/local\/python3\/bin\/python3 \/usr\/local\/bin\/python3\nln -s \/usr\/local\/python3\/bin\/pip3 \/usr\/local\/bin\/pip3<\/code><\/pre>\n<h2>\u9a8c\u8bc1\u662f\u5426\u6210\u529f<\/h2>\n<pre><code class=\"language-shell\">[root@iZbp159egvvktszc82dr5xZ \/]# python3 -V\nPython 3.6.2\n[root@iZbp159egvvktszc82dr5xZ \/]# pip3 -V\npip 9.0.1 from \/usr\/local\/python3\/lib\/python3.6\/site-packages (python 3.6)<\/code><\/pre>\n<h2>\u66f4\u6539pip\u6e90<\/h2>\n<p>\u4fee\u6539\u7cfb\u7edfpip\u5b89\u88c5\u6e90<\/p>\n<pre><code class=\"language-shell\">[lemon@iZbp159egvvktszc82dr5xZ ~]$ pip3 config set global.index-url http:\/\/mirrors.aliyun.com\/pypi\/simple\nWriting to \/home\/lemon\/.config\/pip\/pip.conf\n[lemon@iZbp159egvvktszc82dr5xZ ~]$ vim \/home\/lemon\/.config\/pip\/pip.conf\n###################################\n#\u8fdb\u5165\u540e\u6dfb\u52a0\u4ee5\u4e0b\u5185\u5bb9,\u4fdd\u5b58\u9000\u51fa.\n[global]\nindex-url = https:\/\/mirrors.aliyun.com\/pypi\/simple\n\n[install]\ntrusted-host=mirrors.aliyun.com\n###################################\n[lemon@iZbp159egvvktszc82dr5xZ ~]$ pip3 install django\nDefaulting to user installation because normal site-packages is not writeable\nLooking in indexes: http:\/\/mirrors.aliyun.com\/pypi\/simple\nCollecting django\n  Downloading http:\/\/mirrors.aliyun.com\/pypi\/packages\/a8\/ca\/e88eb097959c48cd313dfc4bc394699a48fe5c158ed3a64c13e4fa46c1fd\/Django-3.2.9-py3-none-any.whl (7.9 MB)\n     |\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588| 7.9 MB 15.1 MB\/s\nCollecting asgiref&lt;4,&gt;=3.3.2\n  Downloading http:\/\/mirrors.aliyun.com\/pypi\/packages\/fe\/66\/577f32b54c50dcd8dec38447258e82ed327ecb86820d67ae7b3dea784f13\/asgiref-3.4.1-py3-none-any.whl (25 kB)\nCollecting pytz\n  Downloading http:\/\/mirrors.aliyun.com\/pypi\/packages\/d3\/e3\/d9f046b5d1c94a3aeab15f1f867aa414f8ee9d196fae6865f1d6a0ee1a0b\/pytz-2021.3-py2.py3-none-any.whl (503 kB)\n     |\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588| 503 kB 129.9 MB\/s\nCollecting sqlparse&gt;=0.2.2\n  Downloading http:\/\/mirrors.aliyun.com\/pypi\/packages\/05\/40\/d836d55fb3f467243ee839ab7b814822fda522cd395fa41e282684e71ee5\/sqlparse-0.4.2-py3-none-any.whl (42 kB)\n     |\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588| 42 kB 25.8 MB\/s\nInstalling collected packages: asgiref, pytz, sqlparse, django\nSuccessfully installed asgiref-3.4.1 django-3.2.9 pytz-2021.3 sqlparse-0.4.2\nWARNING: You are using pip version 20.2.3; however, version 21.3.1 is available.\nYou should consider upgrading via the &#039;\/usr\/local\/python3\/bin\/python3.8 -m pip install --upgrade pip&#039; command.\n[lemon@iZbp159egvvktszc82dr5xZ ~]$\n<\/code><\/pre>\n<h2>root\u5b89\u88c5<\/h2>\n<pre><code class=\"language-shell\">1.\u83b7\u53d6\nwget https:\/\/www.python.org\/ftp\/python\/3.8.6\/Python-3.8.6.tgz\ntar -xzvf  Python-3.8.6.tgz -C \/tmp\ncd \/tmp\/Python-3.8.6\/\n\n2.\u628apython3.8\u5b89\u88c5\u5230 \/usr\/local\u76ee\u5f55\n.\/configure --prefix=\/usr\/local\nmake\nmake altinstall\n\n3.\u66f4\u6539\/usr\/bin\/python\u94fe\u63a5\nln -s \/usr\/local\/bin\/python3.8 \/usr\/bin\/python3\nln -s \/usr\/local\/bin\/pip3.8 \/usr\/bin\/pip3<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u4e0b\u8f7d\u5b89\u88c5\u4f9d\u8d56\u5305 yum install openssl-devel bzip2-devel expat-devel gdbm-devel   \u2026 &#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"ngg_post_thumbnail":0},"categories":[25],"tags":[16],"_links":{"self":[{"href":"\/index.php?rest_route=\/wp\/v2\/posts\/200"}],"collection":[{"href":"\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=200"}],"version-history":[{"count":4,"href":"\/index.php?rest_route=\/wp\/v2\/posts\/200\/revisions"}],"predecessor-version":[{"id":366,"href":"\/index.php?rest_route=\/wp\/v2\/posts\/200\/revisions\/366"}],"wp:attachment":[{"href":"\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=200"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=200"},{"taxonomy":"post_tag","embeddable":true,"href":"\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=200"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}