{"id":185,"date":"2021-10-18T22:32:30","date_gmt":"2021-10-18T14:32:30","guid":{"rendered":"http:\/\/47.98.165.52\/?p=185"},"modified":"2021-11-09T19:23:56","modified_gmt":"2021-11-09T11:23:56","slug":"python%e8%bd%af%e8%bf%9e%e6%8e%a5%e8%ae%be%e7%bd%ae","status":"publish","type":"post","link":"\/?p=185","title":{"rendered":"python\u8f6f\u8fde\u63a5\u8bbe\u7f6e"},"content":{"rendered":"<h3>\u5f53\u524d\u73af\u5883\uff1a<\/h3>\n<p><strong>\u7cfb\u7edf<\/strong>\uff1a<\/p>\n<ul>\n<li>CentOS7.6<\/li>\n<\/ul>\n<p><strong>\u5f53\u524d\u7cfb\u7edf\u4e0bpython\u76f8\u5173\u547d\u4ee4<\/strong>\uff1a<\/p>\n<pre><code>[lemon@iZbp159egvvktszc82dr5xZ vendors]# whereis python\npython: \/usr\/bin\/python2.7-config \n\/usr\/bin\/python2.7 \n\/usr\/bin\/python \n\/usr\/lib\/python2.7 \n\/usr\/lib64\/python2.7 \n\/etc\/python \n\/usr\/local\/bin\/python3.7-config \n\/usr\/local\/bin\/python3.7 \n\/usr\/local\/bin\/python3.7m \n\/usr\/local\/bin\/python3.7m-config \n\/usr\/local\/lib\/python3.7 \n\/usr\/include\/python2.7 \n\/usr\/share\/man\/man1\/python.1.gz<\/code><\/pre>\n<pre><code>[lemon@iZbp159egvvktszc82dr5xZ ~]$ cd \/usr\/bin\n[lemon@iZbp159egvvktszc82dr5xZ bin]$ ls -al python*\n[lemon@iZbp159egvvktszc82dr5xZ bin]$ ls -al python*\nlrwxrwxrwx 1 root root    7 Aug 26 19:08 python -&gt; python2\nlrwxrwxrwx 1 root root    9 Aug 26 19:08 python2 -&gt; python2.7\n-rwxr-xr-x 1 root root 7144 Nov 17  2020 python2.7\n-rwxr-xr-x 1 root root 1835 Nov 17  2020 python2.7-config\nlrwxrwxrwx 1 root root   16 Aug 26 19:08 python2-config -&gt; python2.7-config\nlrwxrwxrwx 1 root root   24 Aug 26 19:53 python3 -&gt; \/opt\/python\/python-3.7.3\nlrwxrwxrwx 1 root root   14 Aug 26 19:08 python-config -&gt; python2-config<\/code><\/pre>\n<p><strong>\u5f53\u524d\u7cfb\u7edf\u6709\u4e24\u4e2a\u7248\u672cpython<\/strong><\/p>\n<ul>\n<li>python2.7.5<\/li>\n<li>python3.7.3<\/li>\n<\/ul>\n<p><strong>\u53c2\u8003\u6587\u7ae0<\/strong><\/p>\n<ul>\n<li><a href=\"https:\/\/www.cnblogs.com\/simuhunluo\/p\/7704765.html\">https:\/\/www.cnblogs.com\/simuhunluo\/p\/7704765.html<\/a><\/li>\n<\/ul>\n<h3>\u5b89\u88c5\u5176\u4ed6\u7248\u672cpython<\/h3>\n<p>\u4e0b\u8f7d\u5730\u5740\uff1a<a href=\"https:\/\/www.python.org\/ftp\/python\/\">https:\/\/www.python.org\/ftp\/python\/<\/a><\/p>\n<p>\u8fd9\u91cc\u9009\u62e9python 3.6.3 \u7248\u672c<\/p>\n<h5><code>1.\u521b\u5efa\u5b58\u653e\u76ee\u5f55<\/code><\/h5>\n<pre><code>[lemon@iZbp159egvvktszc82dr5xZ bin]$ sudo mkdir \/usr\/local\/python3.6\n[lemon@iZbp159egvvktszc82dr5xZ bin]$ cd \/usr\/local\/python3.6\n[lemon@iZbp159egvvktszc82dr5xZ python3.6]$ pwd\n\/usr\/local\/python3.6\n[lemon@iZbp159egvvktszc82dr5xZ python3.6]$ ll\ntotal 0<\/code><\/pre>\n<h5><code>2.\u4e0b\u8f7d\uff0c\u89e3\u538b<\/code><\/h5>\n<pre><code>[lemon@iZbp159egvvktszc82dr5xZ python3.6]$ sudo wget https:\/\/www.python.org\/ftp\/python\/3.6.3\/Python-3.6.3.tgz\n[lemon@iZbp159egvvktszc82dr5xZ python3.6]$ sudo tar -xvf Python-3.6.3.tgz\n[lemon@iZbp159egvvktszc82dr5xZ python3.6]$ ll\ntotal 22148\ndrwxr-xr-x 16  501  501     4096 Oct  3  2017 Python-3.6.3\n-rw-r--r--  1 root root 22673115 Oct  3  2017 Python-3.6.3.tgz<\/code><\/pre>\n<h5><code>3.\u7f16\u8bd1\uff1a<\/code><\/h5>\n<pre><code>[lemon@iZbp159egvvktszc82dr5xZ python3.6]$ cd Python-3.6.3\/\n##########|\u5f53\u524d\u76ee\u5f55\uff1a\/usr\/local\/python3\/Python-3.6.3|######################################\n##########|python3.6Dir\u6587\u4ef6\u5939\u4e3a\u4e34\u65f6\u521b\u5efa|##########################################\n[lemon@iZbp159egvvktszc82dr5xZ Python-3.6.3]$ sudo .\/configure --prefix=\/usr\/local\/python3.6Dir\n[lemon@iZbp159egvvktszc82dr5xZ Python-3.6.3]$ sudo make\n[lemon@iZbp159egvvktszc82dr5xZ Python-3.6.3]$ sudo make install<\/code><\/pre>\n<h5><code>4.\u7f16\u8bd1\u5b8c\u6210\uff0c\u67e5\u770b\u547d\u4ee4<\/code><\/h5>\n<pre><code>[lemon@iZbp159egvvktszc82dr5xZ bin]$ cd \/usr\/local\/python3.6Dir\/bin\/\n[lemon@iZbp159egvvktszc82dr5xZ bin]$ ls\n2to3              idle3    pip3.6    python3           python3.6m         pyvenv\n2to3-3.6          idle3.6  pydoc3    python3.6         python3.6m-config  pyvenv-3.6\neasy_install-3.6  pip3     pydoc3.6  python3.6-config  python3-config<\/code><\/pre>\n<h5><code>5.\u9a8c\u8bc1<\/code><\/h5>\n<p>\u5f53\u524dpython3.6\u547d\u4ee4\u5e76\u4e0d\u5728\u5168\u5c40\u4e2d\uff1a<\/p>\n<pre><code>[lemon@iZbp159egvvktszc82dr5xZ bin]$ python3.6\n-bash: python3.6: command not found\n\n[lemon@iZbp159egvvktszc82dr5xZ bin]$ .\/python3.6\nPython 3.6.3 (default, Sep  4 2021, 11:19:58)\n[GCC 4.8.5 20150623 (Red Hat 4.8.5-44)] on linux\nType &quot;help&quot;, &quot;copyright&quot;, &quot;credits&quot; or &quot;license&quot; for more information.\n>&gt;&gt;<\/code><\/pre>\n<h3>\u5176\u4ed6python\u547d\u4ee4\u7248\u672c\u53ca\u4f4d\u7f6e\uff1a<\/h3>\n<h5>python2.7\uff1a<\/h5>\n<pre><code>[lemon@iZbp159egvvktszc82dr5xZ ~]$ python -V\nPython 2.7.5\n[lemon@iZbp159egvvktszc82dr5xZ ~]$ which python\n\/usr\/bin\/python<\/code><\/pre>\n<h5>python3.7:<\/h5>\n<pre><code>[lemon@iZbp159egvvktszc82dr5xZ ~]$ python3 -V\nPython 3.7.3\n[lemon@iZbp159egvvktszc82dr5xZ ~]$ which python3\n\/usr\/local\/bin\/python3<\/code><\/pre>\n<h3>\u6dfb\u52a0\u8f6f\u94fe\u63a5\uff1a<\/h3>\n<h4><font color=#D2691E>\u4e3apython3.6\u6dfb\u52a0\u522b\u540d\/\u8f6f\u94fe\u63a5\uff1a<\/font><\/h4>\n<h5>1.\u4fdd\u7559usr\/bin\u4e0b\u7684python(\u539f2.7\u7248\u672c)\uff0c\u521b\u5efa\u81f3\/usr\/local\/bin\u76ee\u5f55\u4e0b\uff1a<\/h5>\n<pre><code>[lemon@iZbp159egvvktszc82dr5xZ bin]$ cd \/usr\/local\/bin\n[lemon@iZbp159egvvktszc82dr5xZ bin]$ sudo ln -s \/usr\/local\/python3.6Dir\/bin\/python3 \/usr\/local\/bin\/python3.6\n[lemon@iZbp159egvvktszc82dr5xZ bin]$ pwd\n\/usr\/local\/bin\n[lemon@iZbp159egvvktszc82dr5xZ bin]$ ls python*\npython3  python3.6  python3.7  python3.7-config  python3.7m  python3.7m-config  python3-config<\/code><\/pre>\n<h5>2.\u53ef\u4ee5\u770b\u5230\/usr\/local\/bin\u76ee\u5f55\u4e0b\u7684python\u7684\u76f8\u5173\u6307\u4ee4\uff1a<\/h5>\n<pre><code>[lemon@iZbp159egvvktszc82dr5xZ bin]$ ls -al python*\nlrwxrwxrwx 1 root root        9 Aug 26 19:52 python3 -&gt; python3.7\nlrwxrwxrwx 1 root root       35 Sep  4 12:47 python3.6 -&gt; \/usr\/local\/python3.6Dir\/bin\/python3\n-rwxr-xr-x 2 root root 12635064 Aug 26 19:52 python3.7\nlrwxrwxrwx 1 root root       17 Aug 26 19:52 python3.7-config -&gt; python3.7m-config\n-rwxr-xr-x 2 root root 12635064 Aug 26 19:52 python3.7m\n-rwxr-xr-x 1 root root     3105 Aug 26 19:52 python3.7m-config\nlrwxrwxrwx 1 root root       16 Aug 26 19:52 python3-config -&gt; python3.7-config<\/code><\/pre>\n<h5>3.\u9000\u51fa\u81f3\u6839\u76ee\u5f55\uff0c\u9a8c\u8bc1\u4e00\u4e0b\u8f6f\u94fe\u63a5\u662f\u5426\u53ef\u884c\uff1a<\/h5>\n<pre><code>[lemon@iZbp159egvvktszc82dr5xZ bin]$ cd \/\n[lemon@iZbp159egvvktszc82dr5xZ \/]$ pwd\n\/\n[lemon@iZbp159egvvktszc82dr5xZ \/]$ python3.6\nPython 3.6.3 (default, Sep  4 2021, 11:19:58)\n[GCC 4.8.5 20150623 (Red Hat 4.8.5-44)] on linux\nType &quot;help&quot;, &quot;copyright&quot;, &quot;credits&quot; or &quot;license&quot; for more information.\n>&gt;&gt;\n[lemon@iZbp159egvvktszc82dr5xZ \/]$ python3.7\nPython 3.7.3 (default, Aug 26 2021, 19:51:41)\n[GCC 4.8.5 20150623 (Red Hat 4.8.5-44)] on linux\nType &quot;help&quot;, &quot;copyright&quot;, &quot;credits&quot; or &quot;license&quot; for more information.\n>&gt;&gt;\n[lemon@iZbp159egvvktszc82dr5xZ \/]$ python\nPython 2.7.5 (default, Nov 16 2020, 22:23:17)\n[GCC 4.8.5 20150623 (Red Hat 4.8.5-44)] on linux2\nType &quot;help&quot;, &quot;copyright&quot;, &quot;credits&quot; or &quot;license&quot; for more information.\n>&gt;&gt;<\/code><\/pre>\n<h5>4.\u76f8\u540c\u64cd\u4f5c\uff0c\u518d\u641e\u4e00\u4e0bpip\u6307\u4ee4\uff1a<\/h5>\n<pre><code>[lemon@iZbp159egvvktszc82dr5xZ bin]$ sudo ln -s \/usr\/local\/python3.6Dir\/bin\/pip3.6 \/usr\/local\/bin\/pip3.6\n[sudo] password for lemon:\n[lemon@iZbp159egvvktszc82dr5xZ bin]$ pip3.6 -V\npip 9.0.1 from \/usr\/local\/python3.6Dir\/lib\/python3.6\/site-packages (python 3.6)\n[lemon@iZbp159egvvktszc82dr5xZ bin]$ pip3.7 -V\npip 21.2.4 from \/home\/lemon\/.local\/lib\/python3.7\/site-packages\/pip (python 3.7)\n[lemon@iZbp159egvvktszc82dr5xZ bin]$ pip -V\npip 20.3.4 from \/home\/lemon\/.local\/lib\/python2.7\/site-packages\/pip (python 2.7)<\/code><\/pre>\n<h4><font color=#D2691E>\u4e3apython3.7\u6dfb\u52a0\u522b\u540d\/\u8f6f\u94fe\u63a5\uff1a<\/font><\/h4>\n<p>\u7531<code>which python3<\/code>\u77e5\u5176\u547d\u4ee4\u6240\u5728\u4f4d\u7f6e\uff0c\u901a\u8fc7ln -s \u6dfb\u52a0\u8f6f\u94fe\u63a5\uff0c\u4e5f\u653e\u5728\/bin\u76ee\u5f55\u4e0b<\/p>\n<pre><code class=\"language-[lemon@iZbp159egvvktszc82dr5xZ\">[lemon@iZbp159egvvktszc82dr5xZ ~]$ sudo ln -s \/usr\/local\/bin\/python3 \/usr\/local\/bin\/paisen3\n[sudo] password for lemon:\n[lemon@iZbp159egvvktszc82dr5xZ ~]$ paisen3\nPython 3.7.3 (default, Aug 26 2021, 19:51:41)\n[GCC 4.8.5 20150623 (Red Hat 4.8.5-44)] on linux\nType &quot;help&quot;, &quot;copyright&quot;, &quot;credits&quot; or &quot;license&quot; for more information.\n>&gt;&gt;<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u5f53\u524d\u73af\u5883\uff1a \u7cfb\u7edf\uff1a CentOS7.6 \u5f53\u524d\u7cfb\u7edf\u4e0bpython\u76f8\u5173\u547d\u4ee4\uff1a [lemon@iZbp159egvvktszc82dr5xZ    \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":[15,16],"_links":{"self":[{"href":"\/index.php?rest_route=\/wp\/v2\/posts\/185"}],"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=185"}],"version-history":[{"count":1,"href":"\/index.php?rest_route=\/wp\/v2\/posts\/185\/revisions"}],"predecessor-version":[{"id":186,"href":"\/index.php?rest_route=\/wp\/v2\/posts\/185\/revisions\/186"}],"wp:attachment":[{"href":"\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=185"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=185"},{"taxonomy":"post_tag","embeddable":true,"href":"\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=185"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}