{"id":341,"date":"2018-07-16T14:17:40","date_gmt":"2018-07-16T06:17:40","guid":{"rendered":"http:\/\/blog.lovexu.cc\/?p=341"},"modified":"2020-05-15T14:00:35","modified_gmt":"2020-05-15T06:00:35","slug":"python3%e4%b8%adpip3%e5%ae%89%e8%a3%85%e5%87%ba%e9%94%99%ef%bc%8c%e6%89%be%e4%b8%8d%e5%88%b0ssl","status":"publish","type":"post","link":"https:\/\/lox.im\/index.php\/341.html","title":{"rendered":"python3\u4e2dpip3\u5b89\u88c5\u51fa\u9519\uff0c\u627e\u4e0d\u5230SSL"},"content":{"rendered":"<p>\u8f6c\u8f7d\u81ea<a href=\"https:\/\/blog.csdn.net\/jeryjeryjery\" target=\"_blank\"  rel=\"nofollow\" >\u5218\u4f1f\u7684\u535a\u5ba2<\/a>\u3002<\/p>\n<p>\u6700\u8fd1\u5728centos6.6\u4e0a\u5b89\u88c5Python3.7\u4e4b\u540e\uff0c\u4f7f\u7528pip\u547d\u4ee4\u51fa\u73b0\u4e86\u95ee\u9898\uff0c\u63d0\u793a\u8bf4\u627e\u4e0d\u5230ssl\u6a21\u5757\uff0c\u51fa\u73b0\u9519\u8bef\u5982\u4e0b\uff1a<\/p>\n<pre class=\"prettyprint\" name=\"code\"><code class=\"hljs applescript has-numbering\">pip <span class=\"hljs-keyword\">is<\/span> configured <span class=\"hljs-keyword\">with<\/span> locations <span class=\"hljs-keyword\">that<\/span> require TLS\/SSL, however <span class=\"hljs-keyword\">the<\/span> ssl module <span class=\"hljs-keyword\">in<\/span> Python <span class=\"hljs-keyword\">is<\/span> <span class=\"hljs-keyword\">not<\/span> available.\n\nCould <span class=\"hljs-keyword\">not<\/span> fetch URL https:*******: There was a problem confirming <span class=\"hljs-keyword\">the<\/span> ssl certificate: \nCan't connect <span class=\"hljs-keyword\">to<\/span> HTTPS URL because <span class=\"hljs-keyword\">the<\/span> SSL module <span class=\"hljs-keyword\">is<\/span> <span class=\"hljs-keyword\">not<\/span> available. - skipping<\/code><\/pre>\n<p>\u672c\u4eba\u5b89\u88c5Python3.7\u7684\u64cd\u4f5c\u5982\u4e0b\uff1a<\/p>\n<pre class=\"prettyprint\" name=\"code\"><code class=\"hljs avrasm has-numbering\"><span class=\"hljs-number\">1.<\/span>wget\u83b7\u53d6\u5b89\u88c5\u5305\uff1a\n    wget http:\/\/www<span class=\"hljs-preprocessor\">.python<\/span><span class=\"hljs-preprocessor\">.org<\/span>\/ftp\/python\/<span class=\"hljs-number\">3.7.0<\/span>\/Python-<span class=\"hljs-number\">3.7.0<\/span><span class=\"hljs-preprocessor\">.tgz<\/span>\n\n<span class=\"hljs-number\">2.<\/span>\u89e3\u538b\u5b89\u88c5\u5305\uff1a\n    tar -xvzf Python-<span class=\"hljs-number\">3.7.0<\/span><span class=\"hljs-preprocessor\">.tgz<\/span>\n\n<span class=\"hljs-number\">3.<\/span>\u68c0\u67e5\u5b89\u88c5\u5e73\u53f0\u5c5e\u6027\uff0c\u7cfb\u7edf\u662f\u5426\u6709\u7f16\u8bd1\u65f6\u6240\u9700\u8981\u989d\u5e93\uff0c\u4ee5\u53ca\u5e93\u7684\u7248\u672c\u662f\u5426\u6ee1\u8db3\u7f16\u8bd1\u9700\u8981\n    .\/configure\n\n<span class=\"hljs-number\">4.<\/span>\u7f16\u8bd1\u6e90\u7801\n    make\n\n<span class=\"hljs-number\">5.<\/span>\u6210\u529f\u7f16\u8bd1\u4e4b\u540e\uff0c\u5b89\u88c5\n    sudo make install<\/code><\/pre>\n<p>\u5728\u5b89\u88c5\u5b8c\u4e4b\u540e\uff0c\u6211\u4eec\u5e0c\u671b\u7528pip3\u547d\u4ee4\u6765\u5b89\u88c5numpy\u3002\u9996\u5148\uff0c\u7528\u5982\u4e0b\u547d\u4ee4\u5b89\u88c5pip3:<\/p>\n<pre class=\"prettyprint\" name=\"code\"><code class=\"hljs bash has-numbering\"><span class=\"hljs-built_in\">sudo<\/span> install python3-pip<\/code><\/pre>\n<p>\u5b89\u88c5\u5b8c\u4e4b\u540e\uff0c\u4f7f\u7528pip3\u5b89\u88c5numpy\uff1a<\/p>\n<pre class=\"prettyprint\" name=\"code\"><code class=\"hljs bash has-numbering\"><span class=\"hljs-built_in\">sudo<\/span> pip install python-numpy<\/code><\/pre>\n<p>\u4f46\u662f\u6b64\u65f6\u5c31\u51fa\u9519\u4e86\uff0c\u663e\u793a\u672c\u6587\u5f00\u59cb\u63d0\u5230\u7684\u9519\u8bef\uff0c\u5927\u81f4\u610f\u601d\u5c31\u662f\u5b89\u88c5\u8fc7\u7a0b\u9700\u8981SSL,\u4f46\u662f\u90a3\u4e2aSSL\u627e\u4e0d\u5230\u3002<\/p>\n<p>\u672c\u4eba\u67e5\u9605\u7f51\u4e0a\u8d44\u6599\uff0c\u53d1\u73b0openSSL\u662f\u7cfb\u7edf\u81ea\u5e26\u7684\uff0c\u6240\u4ee5\u4e00\u5b9a\u662f\u5b89\u88c5\u4e86\u7684\uff0c\u672c\u4eba\u7528\u4ee5\u4e0b\u547d\u4ee4\u5c1d\u8bd5\u518d\u6b21\u5b89\u88c5openssl:<\/p>\n<pre class=\"prettyprint\" name=\"code\"><code class=\"hljs lasso has-numbering\">sudo apt<span class=\"hljs-attribute\">-get<\/span> install openssl\nsudo apt<span class=\"hljs-attribute\">-get<\/span> install libssl<span class=\"hljs-attribute\">-dev<\/span><\/code><\/pre>\n<p>\u4f46\u662f\u5b89\u88c5\u7ed3\u679c\u663e\u793a\u662f\u5bf9\u5176\u8fdb\u884c\u66f4\u65b0(update)\uff0c\u8fd9\u8bf4\u660e\u7cfb\u7edf\u5df2\u7ecf\u5b89\u88c5\u4e86openssl\u3002\u4f46\u662fpip3\u5c31\u662f\u627e\u4e0d\u5230ssl\u6a21\u5757\u3002<\/p>\n<p>\u672c\u4eba\u8fdb\u5165python3\u4e2d\uff0c\u7136\u540e\u8fdb\u884cssl\u5bfc\u5165\u64cd\u4f5c:<\/p>\n<pre class=\"prettyprint\" name=\"code\"><code class=\"hljs java has-numbering\"><span class=\"hljs-keyword\">import<\/span> ssl<\/code><\/pre>\n<p>\u7ed3\u679c\u51fa\u9519\uff0c\u9519\u8bef\u5982\u4e0b\uff1a<\/p>\n<pre class=\"prettyprint\" name=\"code\"><code class=\"hljs perl has-numbering\"><span class=\"hljs-keyword\">no<\/span> moudle named _ssl<\/code><\/pre>\n<p>\u663e\u793a\u6ca1\u6709ssl\u6a21\u5757\u3002\u672c\u4eba\u518d\u8fdb\u5165python\u4e2d(\u5373\u7cfb\u7edf\u81ea\u5e26\u7684python2.7\u4e2d)\uff0c\u8fdb\u884cssl\u5bfc\u5165\u64cd\u4f5c:<\/p>\n<pre class=\"prettyprint\" name=\"code\"><code class=\"hljs java has-numbering\"><span class=\"hljs-keyword\">import<\/span> ssl<\/code><\/pre>\n<p>\u53d1\u73b0\u5e76\u6ca1\u6709\u663e\u793a\u9519\u8bef\uff0c\u5bfc\u5165\u6b63\u5e38\u3002\u8fd9\u8bf4\u660eopenssl\u5df2\u7ecf\u5b89\u88c5\u4e86\uff0c\u53ea\u662fpython2\u53ef\u4ee5\u8c03\u7528\uff0c\u65b0\u5b89\u88c5\u7684python3\u5374\u4e0d\u80fd\u8c03\u7528\u3002<\/p>\n<p><strong>\u672c\u4eba\u67e5\u9605\u8d44\u6599\u53d1\u73b0\uff0c\u5728.\/configure\u8fc7\u7a0b\u4e2d\uff0c\u5982\u679c\u6ca1\u6709\u52a0\u4e0a\u2013with-ssl\u53c2\u6570\u65f6\uff0c\u9ed8\u8ba4\u5b89\u88c5\u7684\u8f6f\u4ef6\u6d89\u53ca\u5230ssl\u7684\u529f\u80fd\u4e0d\u53ef\u7528\uff0c\u521a\u597dpip3\u8fc7\u7a0b\u9700\u8981ssl\u6a21\u5757\uff0c\u800c\u7531\u4e8e\u6ca1\u6709\u6307\u5b9a\uff0c\u6240\u4ee5\u8be5\u529f\u80fd\u4e0d\u53ef\u7528\u3002<\/strong><\/p>\n<p>\u89e3\u51b3\u529e\u6cd5\u662f\u91cd\u65b0\u5bf9python3.6\u8fdb\u884c\u7f16\u8bd1\u5b89\u88c5\uff0c\u7528\u4e00\u4e0b\u8fc7\u7a0b\u6765\u5b9e\u73b0\u7f16\u8bd1\u5b89\u88c5:<\/p>\n<pre class=\"prettyprint\" name=\"code\"><code class=\"hljs bash has-numbering\"><span class=\"hljs-built_in\">cd<\/span> Python-<span class=\"hljs-number\">3.6<\/span>.<span class=\"hljs-number\">2<\/span>\n.\/configure --with-ssl\nmake\n<span class=\"hljs-built_in\">sudo<\/span> make install<\/code><\/pre>\n<p>\u8fd9\u6837\u5c31\u5141\u8bb8\u5b89\u88c5\u7684python3\u4f7f\u7528ssl\u529f\u80fd\u6a21\u5757,\u8fdb\u5165python3\u4e2d\uff0c\u6267\u884cimport ssl\u53d1\u73b0\u672a\u51fa\u9519\uff0c\u6b63\u5e38\u518d\u6b21\u8c03\u7528pip3\u6307\u4ee4\u6765\u5b89\u88c5numpy\uff0c\u53d1\u73b0\u6b63\u5e38\uff0c\u95ee\u9898\u89e3\u51b3\uff01<\/p>\n<hr \/>\n<h2>\u7ecf\u4e0a\u8ff0\u540e\u8fd8\u662fSSL\u51fa\u9519\uff0c\u540e\u53c8\u5728<a href=\"https:\/\/blog.csdn.net\/chief_victo\" target=\"_blank\"  rel=\"nofollow\" >chief_victo\u7684\u535a\u5ba2<\/a>\u627e\u5230\u53e6\u4e00\u4e2a\u529e\u6cd5\u3002\u7ed3\u679c\u5931\u8d25\u3002<\/h2>\n<article>\n<div id=\"article_content\" class=\"article_content clearfix csdn-tracking-statistics\" data-pid=\"blog\" data-mod=\"popu_307\" data-dsm=\"post\">\n<div class=\"htmledit_views\">\n<div class=\"artical-content-bak main-content\">\n<div class=\"con artical-content editor-preview-side\">\n<h1>\u5b89\u88c5Python3.7.0<\/h1>\n<hr \/>\n<h3>\u63d0\u793a\u627e\u4e0d\u5230SSL\u6a21\u5757<\/h3>\n<p>python\u5b89\u88c5\u5b8c\u6bd5\u540e\uff0c\u63d0\u793a\u627e\u4e0d\u5230ssl\u6a21\u5757\uff1a<\/p>\n<div class=\"hljs-ln-code\">\n<div class=\"hljs-ln-line\">\n<pre class=\"lang:default decode:true \">[root@localhost ~]# python2.7.5\nPython 2.7.5 (default, Jun 3 2013, 11:08:43)\n[GCC 4.1.2 20080704 (Red Hat 4.1.2-54)] on linux2\nType \"help\", \"copyright\", \"credits\" or \"license\" for more information.\n&gt;&gt;&gt; import ssl\u00a0\nTraceback (most recent call last):\nFile \"&lt;stdin&gt;\", line 1, in &lt;module&gt;\nFile \"\/usr\/local\/python27\/lib\/python2.7\/ssl.py\", line 60, in &lt;module&gt;\nimport _ssl # if we can't import it, let the error propagate\nImportError: No module named _ssl\n&gt;&gt;&gt;<\/pre>\n<p><strong>\u91cd\u65b0\u7f16\u8bd1python\uff08\u53bb\u6389\u6700\u540e4\u884c\u7684\u6ce8\u91ca\uff09<\/strong><\/p>\n<pre class=\"lang:default decode:true\">#\u4fee\u6539Setup\u6587\u4ef6\n\u00a0\nvi \/root\/Python-3.6.5\/Modules\/Setup.dist\n\u00a0\n#\u4fee\u6539\u7ed3\u679c\u5982\u4e0b\uff1a\n\u00a0\n# Socket module helper for socket(2)\n\u00a0\n_socket socketmodule.c timemodule.c\n\u00a0\n\u00a0\n\u00a0\n# Socket module helper for SSL support; you must comment out the other\n\u00a0\n# socket line above, and possibly edit the SSL variable:\n\u00a0\nSSL=\/usr\/local\/ssl\n\u00a0\n_ssl _ssl.c \\\n\u00a0\n-DUSE_SSL -I$(SSL)\/include -I$(SSL)\/include\/openssl \\\n\u00a0\n-L$(SSL)\/lib -lssl -lcrypto<a style=\"font-family: Georgia, 'Times New Roman', 'Bitstream Charter', Times, serif; font-size: 16px;\" name=\"t8\"><\/a><\/pre>\n<\/div>\n<\/div>\n<div class=\"hljs-ln-numbers\"><\/div>\n<h3>\u00a0\u7f16\u8bd1\u5b89\u88c5<\/h3>\n<pre class=\"lang:default decode:true\">.\/configure --prefix=\/usr\/local\/python\n\u00a0\nmake\n\u00a0\nmake install\n<\/pre>\n<div class=\"hljs-ln-code\"><\/div>\n<div class=\"hljs-ln-numbers\">\n<div class=\"hljs-ln-line hljs-ln-n\" data-line-number=\"1\"><span style=\"background-color: #ffffff; font-size: 14pt;\">\u00a0<strong><span style=\"font-family: 'Courier 10 Pitch', Courier, monospace; background-color: #ffffff;\">\u6d4b\u8bd5\uff0c\u8fd8\u662f\u4e0d\u6b63\u5e38\u3002<\/span><\/strong><\/span><\/div>\n<\/div>\n<div class=\"hljs-ln-code\">\n<div class=\"hljs-ln-line\">\n<pre class=\"lang:default decode:true\">[root@localhost ~]# python\n\u00a0\nPython 3.6.4 (default, Jun 3 2013, 14:56:13)\n\u00a0\n[GCC 4.1.2 20080704 (Red Hat 4.1.2-54)] on linux2\n\u00a0\nType \"help\", \"copyright\", \"credits\" or \"license\" for more information.\n\u00a0\n&gt;&gt;&gt; import ssl\n\u00a0\n&gt;&gt;&gt;<\/pre>\n<p>\u7ed3\u679c\u6211\u7684\u95ee\u9898\u8fd8\u662f\u4e0d\u662f\u8fd9\u4e2a\u3002<\/p>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/article>\n<div class=\"article-bar-bottom\">\n<p>\u6211\u7684\u539f\u56e0\u6b7bOpenSSL\u7248\u672c\u592a\u8001\u4e86\uff0c\u9700\u8981\u5b89\u88c5\u6700\u65b0\u7684\u7248\u672c\u3002\u5b89\u88c5\u597d\u540epython3.7\u8fd8\u662f\u4e0d\u80fd\u8bc6\u522b\u6700\u65b0\u7684openssl\uff0c\u6700\u540e\u6211\u5c48\u670d\u4e86\uff0c\u6211\u91cd\u88c5\u7cfb\u7edf\u5230\u6700\u65b0\u7684centos7.5.<\/p>\n<p>\u8fd9\u662f\u4e00\u6b21\u5931\u8d25\u7684\u4f53\u9a8c\uff01<\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u6700\u8fd1\u5728centos6.6\u4e0a\u5b89\u88c5Python3.7\u4e4b\u540e\uff0c\u4f7f\u7528pip\u547d\u4ee4\u51fa\u73b0\u4e86\u95ee\u9898\uff0c\u63d0\u793a\u8bf4\u627e\u4e0d\u5230ssl\u6a21\u5757<\/p>\n","protected":false},"author":1,"featured_media":345,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"emotion":"","emotion_color":"","title_style":"","license":"","footnotes":""},"categories":[4],"tags":[11],"class_list":["post-341","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-internet","tag-11"],"_links":{"self":[{"href":"https:\/\/lox.im\/index.php\/wp-json\/wp\/v2\/posts\/341","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lox.im\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lox.im\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lox.im\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lox.im\/index.php\/wp-json\/wp\/v2\/comments?post=341"}],"version-history":[{"count":0,"href":"https:\/\/lox.im\/index.php\/wp-json\/wp\/v2\/posts\/341\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lox.im\/index.php\/wp-json\/wp\/v2\/media\/345"}],"wp:attachment":[{"href":"https:\/\/lox.im\/index.php\/wp-json\/wp\/v2\/media?parent=341"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lox.im\/index.php\/wp-json\/wp\/v2\/categories?post=341"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lox.im\/index.php\/wp-json\/wp\/v2\/tags?post=341"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}