{"id":1466,"date":"2020-03-13T22:34:00","date_gmt":"2020-03-13T14:34:00","guid":{"rendered":"https:\/\/www.yumefx.com\/?p=1466"},"modified":"2022-03-23T14:41:31","modified_gmt":"2022-03-23T06:41:31","slug":"centos7%e9%83%a8%e7%bd%b2python","status":"publish","type":"post","link":"https:\/\/www.yumefx.com\/?p=1466","title":{"rendered":"CentOS7\u90e8\u7f72python"},"content":{"rendered":"\n<p>\u6d89\u53ca\u5230socket\u901a\u4fe1\uff0c\u679c\u7136\u8fd8\u662flinux\u6bd4\u8f83\u7a33\u5b9a\u554a\u3002<\/p>\n<p>\u6240\u4ee5\u4eca\u5929\u8bb0\u5f55\u4e00\u4e0bpython\u5728CentOS\u4e0a\u7684\u90e8\u7f72\u6b65\u9aa4\u3002<\/p>\n<h1>&nbsp;<\/h1>\n<h1 style=\"text-align: center;\">python2\u5b89\u88c5\u76f8\u5173<\/h1>\n<p>linux\u81ea\u5e26\u7684python2.7\uff0c\u53ea\u662f\u6ca1\u6709pip\uff0c\u5355\u72ec\u88c5pip\u7684\u65b9\u6cd5\u5982\u4e0b\u3002<\/p>\n\n\n\n<pre><span># \u4e0b\u8f7d\u5b89\u88c5\u811a\u672c <\/span>\n<span>curl https:\/\/bootstrap.pypa.io\/get-pip.py -o get-pip.py <\/span>\n<span># \u8fd0\u884c\u5b89\u88c5\u811a\u672c <\/span>\n<span>sudo python get-pip.py <\/span>\n<\/pre>\n\n\n\n<p>\u88c5\u597d\u4e4b\u540e\uff0c\u5e94\u8be5\u5c31\u53ef\u4ee5\u76f4\u63a5pip\u8c03\u7528\u4e86\u3002<\/p>\n<p>\u5982\u679c\u65e0\u6cd5\u8c03\u7528\uff0c\u5219\u627e\u5230pip\u5b89\u88c5\u4f4d\u7f6e\uff0c\u53ef\u80fd\u662f\/usr\/local\/python\/bin\uff0c\u5efa\u7acb\u4e2a\u8f6f\u8fde\u63a5\u3002<\/p>\n\n\n\n<pre><span>ln \/usr\/local\/python\/bin\/pip \/usr\/local\/bin\/pip<\/span>\n<\/pre>\n\n\n\n<h1>&nbsp;<\/h1>\n<h1 style=\"text-align: center;\">python3\u5b89\u88c5\u8fc7\u7a0b<\/h1>\n<p>python3\u9700\u8981\u4e0b\u8f7d\u5b89\u88c5\u5305\u7f16\u8bd1\u5b89\u88c5\uff0c\u5b89\u88c5\u6d41\u7a0b\u5982\u4e0b\u3002<\/p>\n\n\n\n<pre><span># \u5b89\u88c5\u76f8\u5e94\u7684\u7f16\u8bd1\u5de5\u5177<\/span>\n<span>yum -y groupinstall \"Development tools\" <\/span>\n<span>yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel <\/span>\n<span>yum install -y libffi-devel zlib1g-dev <\/span>\n<span>yum install zlib* -y <\/span>\n<span><\/span>\n<span># \u4e0b\u8f7d\u5b89\u88c5\u5305<\/span>\n<span>wget https:\/\/www.python.org\/ftp\/python\/3.7.2\/Python-3.7.2.tar.xz <\/span>\n<span># \u89e3\u538b<\/span>\n<span>tar -xvJf  Python-3.7.2.tar.xz<\/span>\n<span># \u521b\u5efa\u7f16\u8bd1\u5b89\u88c5\u76ee\u5f55<\/span>\n<span>mkdir \/usr\/local\/python3 <\/span>\n<span><\/span>\n<span># \u7f16\u8bd1\u5b89\u88c5<\/span>\n<span>cd Python-3.7.2 <\/span>\n<span>.\/configure --prefix=\/usr\/local\/python3 --enable-optimizations --with-ssl <\/span>\n<span># \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.<\/span>\n<span># \u7b2c\u4e8c\u4e2a\u53ef\u4ee5\u63d0\u9ad8python10%-20%\u4ee3\u7801\u8fd0\u884c\u901f\u5ea6.<\/span>\n<span># \u7b2c\u4e09\u4e2a\u662f\u4e3a\u4e86\u5b89\u88c5pip\u9700\u8981\u7528\u5230ssl,\u540e\u9762\u62a5\u9519\u4f1a\u6709\u63d0\u5230.<\/span>\n<span>make &amp;&amp; make install <\/span>\n<span><\/span>\n<span># \u521b\u5efa\u8f6f\u94fe\u63a5<\/span>\n<span>ln -s \/usr\/local\/python3\/bin\/python3 \/usr\/local\/bin\/python3 <\/span>\n<span>ln -s \/usr\/local\/python3\/bin\/pip3 \/usr\/local\/bin\/pip3 <\/span>\n<\/pre>\n\n\n\n<p>\u7136\u540e\u5c31\u53ef\u4ee5\u4f7f\u7528python3\u6765\u8fd0\u884cpython\u811a\u672c\u4e86\u3002<\/p>\n<h1>&nbsp;<\/h1>\n<h1 style=\"text-align: center;\">pip\u6362\u6e90<\/h1>\n<p>\u56e0\u4e3a\u4e00\u4e9b\u539f\u56e0\uff0cpip\u4e0b\u8f7d\u5b89\u88c5\u901f\u5ea6\u6781\u6162\uff08F**K U G*W\uff09\uff0c\u6240\u4ee5\u56fd\u5185\u4f7f\u7528\u4e0d\u5f97\u4e0d\u6362\u56fd\u5185\u6e90\u3002<\/p>\n<h3>&nbsp;<\/h3>\n<h3>\u4e34\u65f6\u4f7f\u7528<\/h3>\n<p>\u4f7f\u7528pip\u7684\u65f6\u5019\u5728\u540e\u9762\u52a0\u4e0a-i\u53c2\u6570\uff0c\u6307\u5b9apip\u6e90<\/p>\n\n\n\n<pre><span>pip install scrapy -i https:\/\/pypi.tuna.tsinghua.edu.cn\/simple <\/span>\n<\/pre>\n\n\n\n<h3>&nbsp;<\/h3>\n<h3>\u6c38\u4e45\u4fee\u6539<\/h3>\n<p>linux\uff0c\u4fee\u6539 ~\/.pip\/pip.conf (\u6ca1\u6709\u5c31\u521b\u5efa\u4e00\u4e2a)\uff0c \u5185\u5bb9\u5982\u4e0b\uff1a<\/p>\n\n\n\n<pre><span>[global]<\/span>\n<span>index-url = https:\/\/pypi.tuna.tsinghua.edu.cn\/simple <\/span>\n<\/pre>\n\n\n\n<p>windows\uff0c\u5728user\u76ee\u5f55\uff08%HOMEPATH%\uff09\u4e2d\u521b\u5efa\u4e00\u4e2apip\u76ee\u5f55\uff0c\u5982\uff1aC:\\Users\\administrator\\pip\uff0c\u5728pip \u76ee\u5f55\u4e0b\u65b0\u5efa\u6587\u4ef6pip.ini\uff0c\u5185\u5bb9\u5982\u4e0b<\/p>\n\n\n\n<pre><span>[global]<\/span>\n<span>index-url = https:\/\/pypi.tuna.tsinghua.edu.cn\/simple<\/span>\n<span>trusted-host = pypi.tuna.tsinghua.edu.cn <\/span>\n<span>timeout = 6000<\/span>\n<\/pre>\n\n\n\n<p>\u5176\u4e2dtrusted-host\u610f\u601d\u662f\u4fe1\u4efb\u8fd9\u4e2a\u5730\u5740\uff0c\u53ef\u4ee5\u514d\u53bbssl\u9a8c\u8bc1\u3002<\/p>\n<h3>\u00a0<\/h3>\n<h3>\u5e38\u7528\u56fd\u5185\u955c\u50cf\u6e90\uff1a<\/h3>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 \u963f\u91cc\u4e91 \u00a0\u00a0 \u00a0\u00a0 \u00a0\u00a0 \u00a0\u00a0 \u00a0\u00a0 \u00a0\u00a0 \u00a0\u00a0 <a href=\"http:\/\/mirrors.aliyun.com\/pypi\/simple\/\" rel=\"nofollow\">http:\/\/mirrors.aliyun.com\/pypi\/simple\/<\/a>\u00a0<br \/>\u2003\u00a0 \u00a0 \u4e2d\u56fd\u79d1\u6280\u5927\u5b66 \u00a0\u00a0 \u00a0\u00a0 \u00a0\u00a0<a href=\"https:\/\/pypi.mirrors.ustc.edu.cn\/simple\/\" rel=\"nofollow\">https:\/\/pypi.mirrors.ustc.edu.cn\/simple\/<\/a>\u00a0<br \/>\u00a0 \u00a0 \u00a0 \u00a0 \u8c46\u74e3(douban) \u00a0\u00a0 \u00a0\u00a0 <a href=\"http:\/\/pypi.douban.com\/simple\/\" rel=\"nofollow\">http:\/\/pypi.douban.com\/simple\/<\/a>\u00a0<br \/>\u00a0 \u00a0 \u00a0 \u00a0 \u6e05\u534e\u5927\u5b66 \u00a0\u00a0 \u00a0\u00a0 \u00a0\u00a0 \u00a0\u00a0 \u00a0\u00a0 \u00a0<a href=\"https:\/\/pypi.tuna.tsinghua.edu.cn\/simple\/\" rel=\"nofollow\">https:\/\/pypi.tuna.tsinghua.edu.cn\/simple\/<\/a>\u00a0<br \/>\u00a0 \u00a0 \u00a0 \u00a0 \u4e2d\u56fd\u79d1\u5b66\u6280\u672f\u5927\u5b66 <a href=\"http:\/\/pypi.mirrors.ustc.edu.cn\/simple\/\" rel=\"nofollow\">http:\/\/pypi.mirrors.ustc.edu.cn\/simple\/<\/a><\/p>\n<h1>\u00a0<\/h1>\n<h1 style=\"text-align: center;\">pip\u8bbe\u7f6e\u4ee3\u7406<\/h1>\n<p>\u6709\u4e09\u79cd\u5e38\u7528\u65b9\u5f0f\uff1a<\/p>\n<h3>\u00a0<\/h3>\n<h3>1.\u5355\u6b21\u8bbe\u7f6e<\/h3>\n\n\n\n<pre><span>pip install pyqt5 --proxy=\u4ee3\u7406\u670d\u52a1\u5668IP:\u7aef\u53e3\u53f7<\/span>\n<\/pre>\n\n\n\n<h3>&nbsp;<\/h3>\n<h3>2.\u4e34\u65f6\u8bbe\u7f6e\uff08\u91cd\u8fde\u540e\u5931\u6548\uff09<\/h3>\n\n\n\n<pre><span>export http_proxy='http:\/\/\u4ee3\u7406\u670d\u52a1\u5668IP:\u7aef\u53e3\u53f7 <\/span>\n<span>export https_proxy='http:\/\/\u4ee3\u7406\u670d\u52a1\u5668IP:\u7aef\u53e3\u53f7'<\/span>\n<\/pre>\n\n\n\n<h3>&nbsp;<\/h3>\n<h3>3.\u6c38\u4e45\u8bbe\u7f6e<\/h3>\n\n\n\n<pre><span>vim \/etc\/profile\uff1a<\/span>\n<span>export http_proxy='http:\/\/\u4ee3\u7406\u670d\u52a1\u5668IP:\u7aef\u53e3\u53f7'<\/span>\n<span>export https_proxy='http:\/\/\u4ee3\u7406\u670d\u52a1\u5668IP:\u7aef\u53e3\u53f7'<\/span>\n<span><\/span>\n<span>source \/etc\/profile<\/span>\n<\/pre>\n\n\n\n<p>\u5176\u4e2d\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0c\u540e\u4e24\u79cd\u65b9\u6cd5\u662f\u901a\u8fc7\u8bbe\u7f6e\u73af\u5883\u53d8\u91cf\u7684\u65b9\u6cd5\u8bbe\u7f6e\u4ee3\u7406\uff0c\u8fd9\u4e2a\u73af\u5883\u53d8\u91cf\u5176\u4ed6\u7c7b\u4f3c\u7a0b\u5e8f\u4e5f\u4f1a\u8c03\u7528\uff0c\u56e0\u6b64\u4e5f\u53ef\u80fd\u53d7\u5230\u5f71\u54cd\u3002<\/p>\n<h1>&nbsp;<\/h1>\n<h1 style=\"text-align: center;\">python\u811a\u672c\u540e\u53f0\u8fd0\u884c<\/h1>\n\n\n\n<pre><span>nohup python -u test.py &gt; nohup.log 2&gt;&amp;1 &amp;<\/span>\n<\/pre>\n\n\n\n<p>\u542b\u4e49\u89e3\u91ca\uff1a<\/p>\n<p>nohup \u4e0d\u6302\u8d77\u7684\u610f\u601d<\/p>\n<p>-u \u4ee3\u8868\u7a0b\u5e8f\u4e0d\u542f\u7528\u7f13\u5b58\uff0c\u4e5f\u5c31\u662f\u628a\u8f93\u51fa\u76f4\u63a5\u653e\u5230log\u4e2d\uff0c\u6ca1\u8fd9\u4e2a\u53c2\u6570\u7684\u8bdd\uff0clog\u6587\u4ef6\u7684\u751f\u6210\u4f1a\u6709\u5ef6\u8fdf<\/p>\n<p>&gt; nohup.log \u5c06\u8f93\u51fa\u65e5\u5fd7\u4fdd\u5b58\u5230\u8fd9\u4e2alog\u4e2d<\/p>\n<p>2&gt;1 2\u4e0e&gt;\u7ed3\u5408\u4ee3\u8868\u9519\u8bef\u91cd\u5b9a\u5411\uff0c\u800c1\u5219\u4ee3\u8868\u9519\u8bef\u91cd\u5b9a\u5411\u5230\u4e00\u4e2a\u6587\u4ef61\uff0c\u800c\u4e0d\u4ee3\u8868\u6807\u51c6\u8f93\u51fa\uff1b<\/p>\n<p>2&gt;&amp;1 \u6362\u62102&gt;&amp;1\uff0c&amp;\u4e0e1\u7ed3\u5408\u5c31\u4ee3\u8868\u6807\u51c6\u8f93\u51fa\u4e86\uff0c\u5c31\u53d8\u6210\u9519\u8bef\u91cd\u5b9a\u5411\u5230\u6807\u51c6\u8f93\u51fa.<\/p>\n<p>&amp; \u6700\u540e\u4e00\u4e2a&amp; \uff0c\u4ee3\u8868\u8be5\u547d\u4ee4\u5728\u540e\u53f0\u6267\u884c<\/p>\n<p>\u547d\u4ee4\u8fd0\u884c\u540e\u4f1a\u6709\u63d0\u793a\uff0c\u793a\u4f8b\uff1a<\/p>\n<p>[1] 4203<\/p>\n<p>\u4ee3\u8868\u8fdb\u7a0b4203\u4e2d\u8fd0\u884c\u3002<\/p>\n<p>\u8fd0\u884c\u5b8c\u6bd5\u540e\u4e0d\u8981\u76f4\u63a5\u5173\u95ed\u8fde\u63a5\u7a97\u53e3\uff0c\u5c3d\u91cf\u4f7f\u7528exit\u547d\u4ee4\u9000\u51fa\uff0c\u5426\u5219nohup\u53ef\u80fd\u5047\u6b7b\u7761\u7720\u3002<\/p>\n<h3>&nbsp;<\/h3>\n<h3>\u67e5\u770bnohub\u547d\u4ee4\u4e0b\u8fd0\u884c\u7684\u6240\u6709\u540e\u53f0\u8fdb\u7a0b\uff1a<\/h3>\n\n\n\n<pre><span>jobs<\/span>\n<\/pre>\n\n\n\n<h3>&nbsp;<\/h3>\n<h3>\u67e5\u770b\u540e\u53f0\u8fd0\u884c\u7684\u6240\u6709\u8fdb\u7a0b\uff1a<\/h3>\n\n\n\n<pre><span>ps -aux<\/span>\n<\/pre>\n\n\n\n<p>\u67e5\u770b\u540e\u53f0\u8fd0\u884c\u7684\u6240\u6709python \u8fdb\u7a0b\uff1a<\/p>\n\n\n\n<pre><span>ps -aux |grep python<\/span>\n<\/pre>\n\n\n\n<h3>&nbsp;<\/h3>\n<h3>\u5220\u9664\u8fdb\u7a0b<\/h3>\n\n\n\n<pre><span>kill -9 [\u8fdb\u7a0bid]<\/span>\n<\/pre>\n\n\n\n<p>-9 \u7684\u610f\u601d\u662f\u5f3a\u5236\u5220\u9664<\/p>\n<p>\u00a0<\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<p>\u4f60\u4e00\u5b9a\u5f97\u8ba4\u8bc6\u5230\u81ea\u5df1\u60f3\u5f80\u54ea\u4e2a\u65b9\u5411\u53d1\u5c55\uff0c<\/p>\n<p>\u7136\u540e\u4e00\u5b9a\u8981\u5bf9\u51c6\u90a3\u4e2a\u65b9\u5411\u51fa\u53d1\uff0c<\/p>\n<p>\u8981\u9a6c\u4e0a\u3002<\/p>\n<p>\u4f60\u518d\u4e5f\u6d6a\u8d39\u4e0d\u8d77\u591a\u4e00\u79d2\u7684\u65f6\u95f4\u4e86\uff0c<\/p>\n<p>\u4f60\u6d6a\u8d39\u4e0d\u8d77\u3002<\/p>\n<p style=\"text-align: right;\">\u2014\u2014\u300a\u9ea6\u7530\u91cc\u7684\u5b88\u671b\u8005\u300b<\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6d89\u53ca\u5230socket\u901a\u4fe1\uff0c\u679c\u7136\u8fd8\u662flinux\u6bd4\u8f83\u7a33\u5b9a\u554a\u3002 \u6240\u4ee5\u4eca\u5929\u8bb0\u5f55\u4e00\u4e0bpython\u5728CentOS\u4e0a\u7684\u90e8\u7f72\u6b65\u9aa4 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":1477,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[11,12,4],"tags":[41,37,14],"_links":{"self":[{"href":"https:\/\/www.yumefx.com\/index.php?rest_route=\/wp\/v2\/posts\/1466"}],"collection":[{"href":"https:\/\/www.yumefx.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.yumefx.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.yumefx.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.yumefx.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1466"}],"version-history":[{"count":0,"href":"https:\/\/www.yumefx.com\/index.php?rest_route=\/wp\/v2\/posts\/1466\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.yumefx.com\/index.php?rest_route=\/wp\/v2\/media\/1477"}],"wp:attachment":[{"href":"https:\/\/www.yumefx.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1466"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.yumefx.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1466"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.yumefx.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1466"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}