{"id":1148102,"date":"2025-01-13T16:33:02","date_gmt":"2025-01-13T08:33:02","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/1148102.html"},"modified":"2025-01-13T16:33:04","modified_gmt":"2025-01-13T08:33:04","slug":"%e5%a6%82%e4%bd%95%e5%8d%87%e7%ba%a7python3","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/1148102.html","title":{"rendered":"\u5982\u4f55\u5347\u7ea7python3"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/25170311\/4e46699a-eb96-446b-aeff-424ba48de8c6.webp\" alt=\"\u5982\u4f55\u5347\u7ea7python3\" \/><\/p>\n<p><p> <strong>\u4e3a\u4e86\u5347\u7ea7Python3\uff0c\u4f60\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u51e0\u79cd\u65b9\u6cd5\uff1a\u901a\u8fc7\u5305\u7ba1\u7406\u5de5\u5177\u3001\u4f7f\u7528Python\u7248\u672c\u7ba1\u7406\u5de5\u5177\u3001\u4ece\u6e90\u4ee3\u7801\u7f16\u8bd1\u3002<\/strong> <\/p>\n<\/p>\n<p><p><strong>\u5305\u7ba1\u7406\u5de5\u5177<\/strong>\uff1a\u4f8b\u5982\u5728Ubuntu\u4e0a\u4f7f\u7528apt-get\u547d\u4ee4\u6765\u5347\u7ea7Python\u7248\u672c\u3002\u8fd9\u662f\u6700\u7b80\u5355\u548c\u76f4\u63a5\u7684\u65b9\u6cd5\uff0c\u56e0\u4e3a\u5b83\u5229\u7528\u64cd\u4f5c\u7cfb\u7edf\u7684\u5305\u7ba1\u7406\u7cfb\u7edf\u6765\u5904\u7406\u4f9d\u8d56\u548c\u517c\u5bb9\u6027\u95ee\u9898\u3002\u5177\u4f53\u6b65\u9aa4\u5982\u4e0b\uff1a\u6253\u5f00\u7ec8\u7aef\uff0c\u8fd0\u884c\u547d\u4ee4<code>sudo apt-get update<\/code>\uff0c\u7136\u540e\u8fd0\u884c<code>sudo apt-get install python3<\/code>\u3002\u8fd9\u6837\u53ef\u4ee5\u786e\u4fdd\u4f60\u5b89\u88c5\u7684\u662f\u6700\u65b0\u7684Python3\u7248\u672c\u3002<\/p>\n<\/p>\n<p><p>\u63a5\u4e0b\u6765\uff0c\u6211\u4eec\u5c06\u8be6\u7ec6\u8ba8\u8bba\u5982\u4f55\u4f7f\u7528\u5305\u7ba1\u7406\u5de5\u5177\u6765\u5347\u7ea7Python3\u3002<\/p>\n<\/p>\n<p><h3>\u4e00\u3001\u4f7f\u7528\u5305\u7ba1\u7406\u5de5\u5177<\/h3>\n<\/p>\n<p><h4>1\u3001Ubuntu\/Debian\u7cfb\u7edf<\/h4>\n<\/p>\n<p><p>\u5728\u57fa\u4e8eDebian\u7684\u7cfb\u7edf\uff08\u5982Ubuntu\uff09\u4e0a\uff0c\u5305\u7ba1\u7406\u5de5\u5177\u662fapt-get\u3002\u4ee5\u4e0b\u662f\u5177\u4f53\u6b65\u9aa4\uff1a<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u66f4\u65b0\u5305\u5217\u8868<\/strong>\uff1a<\/p>\n<\/p>\n<p><p>\u9996\u5148\uff0c\u6253\u5f00\u7ec8\u7aef\u5e76\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\u6765\u66f4\u65b0\u5305\u5217\u8868\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-shell\">sudo apt-get update<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u5c06\u786e\u4fdd\u4f60\u83b7\u53d6\u6700\u65b0\u7684\u8f6f\u4ef6\u5305\u4fe1\u606f\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u5b89\u88c5Python3<\/strong>\uff1a<\/p>\n<\/p>\n<p><p>\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\u6765\u5b89\u88c5\u6700\u65b0\u7684Python3\u7248\u672c\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-shell\">sudo apt-get install python3<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u4e2a\u547d\u4ee4\u4f1a\u81ea\u52a8\u4e0b\u8f7d\u5e76\u5b89\u88c5\u6700\u65b0\u7684Python3\u7248\u672c\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u9a8c\u8bc1\u5b89\u88c5<\/strong>\uff1a<\/p>\n<\/p>\n<p><p>\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u4f60\u53ef\u4ee5\u901a\u8fc7\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\u6765\u9a8c\u8bc1\u662f\u5426\u6210\u529f\u5b89\u88c5\u4e86\u6700\u65b0\u7684Python3\u7248\u672c\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-shell\">python3 --version<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8be5\u547d\u4ee4\u5c06\u663e\u793a\u5f53\u524d\u5b89\u88c5\u7684Python3\u7248\u672c\u53f7\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><h4>2\u3001CentOS\/Fedora\u7cfb\u7edf<\/h4>\n<\/p>\n<p><p>\u5728\u57fa\u4e8eRedHat\u7684\u7cfb\u7edf\uff08\u5982CentOS\u548cFedora\uff09\u4e0a\uff0c\u5305\u7ba1\u7406\u5de5\u5177\u662fyum\u6216dnf\u3002\u4ee5\u4e0b\u662f\u5177\u4f53\u6b65\u9aa4\uff1a<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u66f4\u65b0\u5305\u5217\u8868<\/strong>\uff1a<\/p>\n<\/p>\n<p><p>\u5728\u7ec8\u7aef\u4e2d\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\u6765\u66f4\u65b0\u5305\u5217\u8868\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-shell\">sudo yum update<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u6216\u8005\u5728Fedora\u4e0a\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-shell\">sudo dnf update<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u5b89\u88c5Python3<\/strong>\uff1a<\/p>\n<\/p>\n<p><p>\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\u6765\u5b89\u88c5\u6700\u65b0\u7684Python3\u7248\u672c\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-shell\">sudo yum install python3<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u6216\u8005\u5728Fedora\u4e0a\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-shell\">sudo dnf install python3<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u9a8c\u8bc1\u5b89\u88c5<\/strong>\uff1a<\/p>\n<\/p>\n<p><p>\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u4f60\u53ef\u4ee5\u901a\u8fc7\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\u6765\u9a8c\u8bc1\u662f\u5426\u6210\u529f\u5b89\u88c5\u4e86\u6700\u65b0\u7684Python3\u7248\u672c\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-shell\">python3 --version<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8be5\u547d\u4ee4\u5c06\u663e\u793a\u5f53\u524d\u5b89\u88c5\u7684Python3\u7248\u672c\u53f7\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><h3>\u4e8c\u3001\u4f7f\u7528Python\u7248\u672c\u7ba1\u7406\u5de5\u5177<\/h3>\n<\/p>\n<p><p>\u4f7f\u7528Python\u7248\u672c\u7ba1\u7406\u5de5\u5177\uff0c\u5982pyenv\uff0c\u53ef\u4ee5\u8ba9\u4f60\u8f7b\u677e\u7ba1\u7406\u591a\u4e2aPython\u7248\u672c\uff0c\u5e76\u5728\u4e0d\u540c\u9879\u76ee\u4e4b\u95f4\u5207\u6362\u3002\u4ee5\u4e0b\u662f\u5177\u4f53\u6b65\u9aa4\uff1a<\/p>\n<\/p>\n<p><h4>1\u3001\u5b89\u88c5pyenv<\/h4>\n<\/p>\n<p><p>\u9996\u5148\uff0c\u4f60\u9700\u8981\u5b89\u88c5pyenv\u3002\u4ee5\u4e0b\u662f\u5728Ubuntu\u4e0a\u7684\u5b89\u88c5\u6b65\u9aa4\uff1a<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u5b89\u88c5\u4f9d\u8d56<\/strong>\uff1a<\/p>\n<\/p>\n<p><p>\u6253\u5f00\u7ec8\u7aef\u5e76\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\u6765\u5b89\u88c5pyenv\u6240\u9700\u7684\u4f9d\u8d56\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-shell\">sudo apt-get update<\/p>\n<p>sudo apt-get install -y make build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev libncursesw5-dev xz-utils tk-dev libffi-dev liblzma-dev python-openssl git<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u5b89\u88c5pyenv<\/strong>\uff1a<\/p>\n<\/p>\n<p><p>\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\u6765\u5b89\u88c5pyenv\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-shell\">curl https:\/\/pyenv.run | bash<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u914d\u7f6e\u73af\u5883\u53d8\u91cf<\/strong>\uff1a<\/p>\n<\/p>\n<p><p>\u7f16\u8f91\u4f60\u7684shell\u914d\u7f6e\u6587\u4ef6\uff08\u5982<del>\/.bashrc\u6216<\/del>\/.zshrc\uff09\uff0c\u5e76\u6dfb\u52a0\u4ee5\u4e0b\u5185\u5bb9\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-shell\">export PATH=&quot;$HOME\/.pyenv\/bin:$PATH&quot;<\/p>\n<p>eval &quot;$(pyenv init --path)&quot;<\/p>\n<p>eval &quot;$(pyenv init -)&quot;<\/p>\n<p>eval &quot;$(pyenv virtualenv-init -)&quot;<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u4fdd\u5b58\u5e76\u5173\u95ed\u6587\u4ef6\uff0c\u7136\u540e\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\u4f7f\u914d\u7f6e\u751f\u6548\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-shell\">source ~\/.bashrc<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<\/ol>\n<p><h4>2\u3001\u5b89\u88c5\u548c\u5207\u6362Python\u7248\u672c<\/h4>\n<\/p>\n<ol>\n<li>\n<p><strong>\u5b89\u88c5\u65b0\u7248\u672c\u7684Python<\/strong>\uff1a<\/p>\n<\/p>\n<p><p>\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\u6765\u5b89\u88c5\u4f60\u9700\u8981\u7684Python\u7248\u672c\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-shell\">pyenv install 3.x.x<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5c06<code>3.x.x<\/code>\u66ff\u6362\u4e3a\u4f60\u60f3\u8981\u5b89\u88c5\u7684\u5177\u4f53Python\u7248\u672c\u53f7\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u8bbe\u7f6e\u5168\u5c40Python\u7248\u672c<\/strong>\uff1a<\/p>\n<\/p>\n<p><p>\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\u6765\u8bbe\u7f6e\u9ed8\u8ba4\u7684\u5168\u5c40Python\u7248\u672c\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-shell\">pyenv global 3.x.x<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u6837\uff0c\u7cfb\u7edf\u5c06\u9ed8\u8ba4\u4f7f\u7528\u4f60\u6307\u5b9a\u7684Python\u7248\u672c\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u9a8c\u8bc1\u5b89\u88c5<\/strong>\uff1a<\/p>\n<\/p>\n<p><p>\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u4f60\u53ef\u4ee5\u901a\u8fc7\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\u6765\u9a8c\u8bc1\u662f\u5426\u6210\u529f\u5b89\u88c5\u4e86\u65b0\u7248\u672c\u7684Python\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-shell\">python --version<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8be5\u547d\u4ee4\u5c06\u663e\u793a\u5f53\u524d\u4f7f\u7528\u7684Python\u7248\u672c\u53f7\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><h3>\u4e09\u3001\u4ece\u6e90\u4ee3\u7801\u7f16\u8bd1\u5b89\u88c5Python<\/h3>\n<\/p>\n<p><p>\u5982\u679c\u4f60\u9700\u8981\u7279\u5b9a\u7248\u672c\u7684Python\uff0c\u6216\u8005\u4f60\u7684\u64cd\u4f5c\u7cfb\u7edf\u6ca1\u6709\u63d0\u4f9b\u6240\u9700\u7684Python\u7248\u672c\uff0c\u4f60\u53ef\u4ee5\u9009\u62e9\u4ece\u6e90\u4ee3\u7801\u7f16\u8bd1\u5b89\u88c5Python\u3002\u4ee5\u4e0b\u662f\u5177\u4f53\u6b65\u9aa4\uff1a<\/p>\n<\/p>\n<p><h4>1\u3001\u4e0b\u8f7dPython\u6e90\u4ee3\u7801<\/h4>\n<\/p>\n<ol>\n<li>\n<p><strong>\u8bbf\u95eePython\u5b98\u7f51<\/strong>\uff1a<\/p>\n<\/p>\n<p><p>\u6253\u5f00\u6d4f\u89c8\u5668\uff0c\u8bbf\u95eePython\u5b98\u7f51\uff08<a href=\"https:\/\/www.python.org\/%EF%BC%89%EF%BC%8C%E7%84%B6%E5%90%8E%E5%AF%BC%E8%88%AA%E5%88%B0%E4%B8%8B%E8%BD%BD%E9%A1%B5%E9%9D%A2%E3%80%82\">https:\/\/www.python.org\/\uff09\uff0c\u7136\u540e\u5bfc\u822a\u5230\u4e0b\u8f7d\u9875\u9762\u3002<\/a><\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u9009\u62e9\u7248\u672c<\/strong>\uff1a<\/p>\n<\/p>\n<p><p>\u627e\u5230\u4f60\u9700\u8981\u7684Python\u7248\u672c\uff0c\u7136\u540e\u70b9\u51fb\u4e0b\u8f7d\u94fe\u63a5\u4ee5\u83b7\u53d6\u6e90\u4ee3\u7801\u538b\u7f29\u5305\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u89e3\u538b\u6e90\u4ee3\u7801<\/strong>\uff1a<\/p>\n<\/p>\n<p><p>\u4e0b\u8f7d\u5b8c\u6210\u540e\uff0c\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u89e3\u538b\u6e90\u4ee3\u7801\u538b\u7f29\u5305\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-shell\">tar -xvf Python-3.x.x.tgz<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5c06<code>3.x.x<\/code>\u66ff\u6362\u4e3a\u4f60\u4e0b\u8f7d\u7684\u5177\u4f53Python\u7248\u672c\u53f7\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><h4>2\u3001\u7f16\u8bd1\u548c\u5b89\u88c5Python<\/h4>\n<\/p>\n<ol>\n<li>\n<p><strong>\u8fdb\u5165\u6e90\u4ee3\u7801\u76ee\u5f55<\/strong>\uff1a<\/p>\n<\/p>\n<p><p>\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u8fdb\u5165\u89e3\u538b\u540e\u7684\u6e90\u4ee3\u7801\u76ee\u5f55\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-shell\">cd Python-3.x.x<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u914d\u7f6e\u7f16\u8bd1\u9009\u9879<\/strong>\uff1a<\/p>\n<\/p>\n<p><p>\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\u914d\u7f6e\u7f16\u8bd1\u9009\u9879\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-shell\">.\/configure --enable-optimizations<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u4e2a\u547d\u4ee4\u5c06\u8fdb\u884c\u4e00\u7cfb\u5217\u68c0\u67e5\uff0c\u5e76\u751f\u6210Makefile\u6587\u4ef6\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u7f16\u8bd1Python<\/strong>\uff1a<\/p>\n<\/p>\n<p><p>\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\u7f16\u8bd1Python\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-shell\">make -j 8<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5176\u4e2d<code>-j 8<\/code>\u8868\u793a\u4f7f\u75288\u4e2a\u5e76\u884c\u7ebf\u7a0b\u8fdb\u884c\u7f16\u8bd1\uff0c\u4f60\u53ef\u4ee5\u6839\u636e\u4f60\u7684CPU\u6838\u5fc3\u6570\u8fdb\u884c\u8c03\u6574\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u5b89\u88c5Python<\/strong>\uff1a<\/p>\n<\/p>\n<p><p>\u7f16\u8bd1\u5b8c\u6210\u540e\uff0c\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\u8fdb\u884c\u5b89\u88c5\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-shell\">sudo make altinstall<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u6ce8\u610f\uff1a\u4f7f\u7528<code>altinstall<\/code>\u800c\u4e0d\u662f<code>install<\/code>\uff0c\u8fd9\u6837\u53ef\u4ee5\u907f\u514d\u8986\u76d6\u7cfb\u7edf\u9ed8\u8ba4\u7684Python\u7248\u672c\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u9a8c\u8bc1\u5b89\u88c5<\/strong>\uff1a<\/p>\n<\/p>\n<p><p>\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u4f60\u53ef\u4ee5\u901a\u8fc7\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\u6765\u9a8c\u8bc1\u662f\u5426\u6210\u529f\u5b89\u88c5\u4e86\u65b0\u7248\u672c\u7684Python\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-shell\">python3.x --version<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5c06<code>3.x<\/code>\u66ff\u6362\u4e3a\u4f60\u5b89\u88c5\u7684\u5177\u4f53Python\u7248\u672c\u53f7\u3002\u8be5\u547d\u4ee4\u5c06\u663e\u793a\u5f53\u524d\u5b89\u88c5\u7684Python\u7248\u672c\u53f7\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><h3>\u56db\u3001\u5728Windows\u4e0a\u5347\u7ea7Python3<\/h3>\n<\/p>\n<p><p>\u5728Windows\u4e0a\uff0c\u5347\u7ea7Python3\u7684\u65b9\u6cd5\u4e3b\u8981\u662f\u901a\u8fc7\u4e0b\u8f7d\u5b89\u88c5\u5305\u548c\u4f7f\u7528\u5305\u7ba1\u7406\u5de5\u5177\u3002<\/p>\n<\/p>\n<p><h4>1\u3001\u901a\u8fc7\u4e0b\u8f7d\u5b89\u88c5\u5305\u5347\u7ea7<\/h4>\n<\/p>\n<ol>\n<li>\n<p><strong>\u8bbf\u95eePython\u5b98\u7f51<\/strong>\uff1a<\/p>\n<\/p>\n<p><p>\u6253\u5f00\u6d4f\u89c8\u5668\uff0c\u8bbf\u95eePython\u5b98\u7f51\uff08<a href=\"https:\/\/www.python.org\/%EF%BC%89%EF%BC%8C%E7%84%B6%E5%90%8E%E5%AF%BC%E8%88%AA%E5%88%B0%E4%B8%8B%E8%BD%BD%E9%A1%B5%E9%9D%A2%E3%80%82\">https:\/\/www.python.org\/\uff09\uff0c\u7136\u540e\u5bfc\u822a\u5230\u4e0b\u8f7d\u9875\u9762\u3002<\/a><\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u9009\u62e9\u7248\u672c<\/strong>\uff1a<\/p>\n<\/p>\n<p><p>\u627e\u5230\u4f60\u9700\u8981\u7684Python\u7248\u672c\uff0c\u7136\u540e\u70b9\u51fb\u4e0b\u8f7d\u94fe\u63a5\u4ee5\u83b7\u53d6Windows\u5b89\u88c5\u5305\uff08\u901a\u5e38\u662f.exe\u6587\u4ef6\uff09\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u8fd0\u884c\u5b89\u88c5\u5305<\/strong>\uff1a<\/p>\n<\/p>\n<p><p>\u4e0b\u8f7d\u5b8c\u6210\u540e\uff0c\u53cc\u51fb\u8fd0\u884c\u5b89\u88c5\u5305\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u9009\u62e9\u5b89\u88c5\u9009\u9879<\/strong>\uff1a<\/p>\n<\/p>\n<p><p>\u5728\u5b89\u88c5\u5411\u5bfc\u4e2d\uff0c\u9009\u62e9\u201cAdd Python to PATH\u201d\u9009\u9879\uff0c\u8fd9\u5c06\u81ea\u52a8\u914d\u7f6e\u73af\u5883\u53d8\u91cf\u3002\u7136\u540e\u70b9\u51fb\u201cInstall Now\u201d\u6309\u94ae\u5f00\u59cb\u5b89\u88c5\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u5b8c\u6210\u5b89\u88c5<\/strong>\uff1a<\/p>\n<\/p>\n<p><p>\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u4f60\u53ef\u4ee5\u901a\u8fc7\u8fd0\u884c\u547d\u4ee4\u63d0\u793a\u7b26\uff0c\u5e76\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\u6765\u9a8c\u8bc1\u662f\u5426\u6210\u529f\u5b89\u88c5\u4e86\u65b0\u7248\u672c\u7684Python\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-shell\">python --version<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8be5\u547d\u4ee4\u5c06\u663e\u793a\u5f53\u524d\u5b89\u88c5\u7684Python\u7248\u672c\u53f7\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><h4>2\u3001\u4f7f\u7528\u5305\u7ba1\u7406\u5de5\u5177\u5347\u7ea7<\/h4>\n<\/p>\n<p><p>Windows\u4e0a\u6709\u4e00\u4e2a\u540d\u4e3aChocolatey\u7684\u5305\u7ba1\u7406\u5de5\u5177\uff0c\u53ef\u4ee5\u65b9\u4fbf\u5730\u7ba1\u7406\u8f6f\u4ef6\u5305\uff0c\u5305\u62ecPython\u3002<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u5b89\u88c5Chocolatey<\/strong>\uff1a<\/p>\n<\/p>\n<p><p>\u6253\u5f00\u547d\u4ee4\u63d0\u793a\u7b26\uff0c\u4ee5\u7ba1\u7406\u5458\u8eab\u4efd\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\u6765\u5b89\u88c5Chocolatey\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-shell\">@&quot;%SystemRoot%\\System32\\WindowsPowerShell\\v1.0\\powershell.exe&quot; -NoProfile -InputFormat None -ExecutionPolicy Bypass -Command &quot;iex ((New-Object System.Net.WebClient).DownloadString(&#39;https:\/\/chocolatey.org\/install.ps1&#39;))&quot; &amp;&amp; SET &quot;PATH=%PATH%;%ALLUSERSPROFILE%\\chocolatey\\bin&quot;<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u4f7f\u7528Chocolatey\u5b89\u88c5Python<\/strong>\uff1a<\/p>\n<\/p>\n<p><p>\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\u6765\u5b89\u88c5\u6216\u5347\u7ea7Python\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-shell\">choco install python --version=3.x.x<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5c06<code>3.x.x<\/code>\u66ff\u6362\u4e3a\u4f60\u9700\u8981\u5b89\u88c5\u7684\u5177\u4f53Python\u7248\u672c\u53f7\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u9a8c\u8bc1\u5b89\u88c5<\/strong>\uff1a<\/p>\n<\/p>\n<p><p>\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u4f60\u53ef\u4ee5\u901a\u8fc7\u8fd0\u884c\u547d\u4ee4\u63d0\u793a\u7b26\uff0c\u5e76\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\u6765\u9a8c\u8bc1\u662f\u5426\u6210\u529f\u5b89\u88c5\u4e86\u65b0\u7248\u672c\u7684Python\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-shell\">python --version<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8be5\u547d\u4ee4\u5c06\u663e\u793a\u5f53\u524d\u5b89\u88c5\u7684Python\u7248\u672c\u53f7\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><h3>\u4e94\u3001\u5728macOS\u4e0a\u5347\u7ea7Python3<\/h3>\n<\/p>\n<p><p>\u5728macOS\u4e0a\uff0c\u5347\u7ea7Python3\u7684\u65b9\u6cd5\u4e3b\u8981\u662f\u901a\u8fc7Homebrew\u5305\u7ba1\u7406\u5de5\u5177\u548c\u4ece\u6e90\u4ee3\u7801\u7f16\u8bd1\u5b89\u88c5\u3002<\/p>\n<\/p>\n<p><h4>1\u3001\u4f7f\u7528Homebrew\u5305\u7ba1\u7406\u5de5\u5177<\/h4>\n<\/p>\n<p><p>Homebrew\u662fmacOS\u4e0a\u7684\u4e00\u4e2a\u6d41\u884c\u5305\u7ba1\u7406\u5de5\u5177\uff0c\u53ef\u4ee5\u65b9\u4fbf\u5730\u7ba1\u7406\u8f6f\u4ef6\u5305\uff0c\u5305\u62ecPython\u3002<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u5b89\u88c5Homebrew<\/strong>\uff1a<\/p>\n<\/p>\n<p><p>\u5982\u679c\u4f60\u8fd8\u6ca1\u6709\u5b89\u88c5Homebrew\uff0c\u53ef\u4ee5\u6253\u5f00\u7ec8\u7aef\u5e76\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\u6765\u5b89\u88c5\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-shell\">\/bin\/bash -c &quot;$(curl -fsSL https:\/\/raw.githubusercontent.com\/Homebrew\/install\/HEAD\/install.sh)&quot;<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u66f4\u65b0Homebrew<\/strong>\uff1a<\/p>\n<\/p>\n<p><p>\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\u6765\u66f4\u65b0Homebrew\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-shell\">brew update<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u5b89\u88c5\u6216\u5347\u7ea7Python<\/strong>\uff1a<\/p>\n<\/p>\n<p><p>\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\u6765\u5b89\u88c5\u6216\u5347\u7ea7Python\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-shell\">brew install python<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5982\u679c\u4f60\u5df2\u7ecf\u5b89\u88c5\u4e86Python\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u6765\u5347\u7ea7\u5230\u6700\u65b0\u7248\u672c\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-shell\">brew upgrade python<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u9a8c\u8bc1\u5b89\u88c5<\/strong>\uff1a<\/p>\n<\/p>\n<p><p>\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u4f60\u53ef\u4ee5\u901a\u8fc7\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\u6765\u9a8c\u8bc1\u662f\u5426\u6210\u529f\u5b89\u88c5\u4e86\u65b0\u7248\u672c\u7684Python\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-shell\">python3 --version<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8be5\u547d\u4ee4\u5c06\u663e\u793a\u5f53\u524d\u5b89\u88c5\u7684Python\u7248\u672c\u53f7\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><h4>2\u3001\u4ece\u6e90\u4ee3\u7801\u7f16\u8bd1\u5b89\u88c5Python<\/h4>\n<\/p>\n<p><p>\u5982\u679c\u4f60\u9700\u8981\u7279\u5b9a\u7248\u672c\u7684Python\uff0c\u6216\u8005Homebrew\u6ca1\u6709\u63d0\u4f9b\u6240\u9700\u7684Python\u7248\u672c\uff0c\u4f60\u53ef\u4ee5\u9009\u62e9\u4ece\u6e90\u4ee3\u7801\u7f16\u8bd1\u5b89\u88c5Python\u3002\u4ee5\u4e0b\u662f\u5177\u4f53\u6b65\u9aa4\uff1a<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u4e0b\u8f7dPython\u6e90\u4ee3\u7801<\/strong>\uff1a<\/p>\n<\/p>\n<p><p>\u8bbf\u95eePython\u5b98\u7f51\uff08<a href=\"https:\/\/www.python.org\/%EF%BC%89%EF%BC%8C%E7%84%B6%E5%90%8E%E5%AF%BC%E8%88%AA%E5%88%B0%E4%B8%8B%E8%BD%BD%E9%A1%B5%E9%9D%A2%E3%80%82%E6%89%BE%E5%88%B0%E4%BD%A0%E9%9C%80%E8%A6%81%E7%9A%84Python%E7%89%88%E6%9C%AC%EF%BC%8C%E7%84%B6%E5%90%8E%E7%82%B9%E5%87%BB%E4%B8%8B%E8%BD%BD%E9%93%BE%E6%8E%A5%E4%BB%A5%E8%8E%B7%E5%8F%96%E6%BA%90%E4%BB%A3%E7%A0%81%E5%8E%8B%E7%BC%A9%E5%8C%85%E3%80%82\">https:\/\/www.python.org\/\uff09\uff0c\u7136\u540e\u5bfc\u822a\u5230\u4e0b\u8f7d\u9875\u9762\u3002\u627e\u5230\u4f60\u9700\u8981\u7684Python\u7248\u672c\uff0c\u7136\u540e\u70b9\u51fb\u4e0b\u8f7d\u94fe\u63a5\u4ee5\u83b7\u53d6\u6e90\u4ee3\u7801\u538b\u7f29\u5305\u3002<\/a><\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u89e3\u538b\u6e90\u4ee3\u7801<\/strong>\uff1a<\/p>\n<\/p>\n<p><p>\u4e0b\u8f7d\u5b8c\u6210\u540e\uff0c\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u89e3\u538b\u6e90\u4ee3\u7801\u538b\u7f29\u5305\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-shell\">tar -xvf Python-3.x.x.tgz<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5c06<code>3.x.x<\/code>\u66ff\u6362\u4e3a\u4f60\u4e0b\u8f7d\u7684\u5177\u4f53Python\u7248\u672c\u53f7\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u8fdb\u5165\u6e90\u4ee3\u7801\u76ee\u5f55<\/strong>\uff1a<\/p>\n<\/p>\n<p><p>\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u8fdb\u5165\u89e3\u538b\u540e\u7684\u6e90\u4ee3\u7801\u76ee\u5f55\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-shell\">cd Python-3.x.x<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u914d\u7f6e\u7f16\u8bd1\u9009\u9879<\/strong>\uff1a<\/p>\n<\/p>\n<p><p>\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\u914d\u7f6e\u7f16\u8bd1\u9009\u9879\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-shell\">.\/configure --enable-optimizations<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u4e2a\u547d\u4ee4\u5c06\u8fdb\u884c\u4e00\u7cfb\u5217\u68c0\u67e5\uff0c\u5e76\u751f\u6210Makefile\u6587\u4ef6\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u7f16\u8bd1Python<\/strong>\uff1a<\/p>\n<\/p>\n<p><p>\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\u7f16\u8bd1Python\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-shell\">make -j 8<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5176\u4e2d<code>-j 8<\/code>\u8868\u793a\u4f7f\u75288\u4e2a\u5e76\u884c\u7ebf\u7a0b\u8fdb\u884c\u7f16\u8bd1\uff0c\u4f60\u53ef\u4ee5\u6839\u636e\u4f60\u7684CPU\u6838\u5fc3\u6570\u8fdb\u884c\u8c03\u6574\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u5b89\u88c5Python<\/strong>\uff1a<\/p>\n<\/p>\n<p><p>\u7f16\u8bd1\u5b8c\u6210\u540e\uff0c\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\u8fdb\u884c\u5b89\u88c5\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-shell\">sudo make altinstall<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u6ce8\u610f\uff1a\u4f7f\u7528<code>altinstall<\/code>\u800c\u4e0d\u662f<code>install<\/code>\uff0c\u8fd9\u6837\u53ef\u4ee5\u907f\u514d\u8986\u76d6\u7cfb\u7edf\u9ed8\u8ba4\u7684Python\u7248\u672c\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u9a8c\u8bc1\u5b89\u88c5<\/strong>\uff1a<\/p>\n<\/p>\n<p><p>\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u4f60\u53ef\u4ee5\u901a\u8fc7\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\u6765\u9a8c\u8bc1\u662f\u5426\u6210\u529f\u5b89\u88c5\u4e86\u65b0\u7248\u672c\u7684Python\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-shell\">python3.x --version<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5c06<code>3.x<\/code>\u66ff\u6362\u4e3a\u4f60\u5b89\u88c5\u7684\u5177\u4f53Python\u7248\u672c\u53f7\u3002\u8be5\u547d\u4ee4\u5c06\u663e\u793a\u5f53\u524d\u5b89\u88c5\u7684Python\u7248\u672c\u53f7\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><h3>\u516d\u3001\u5728\u4e0d\u540c\u73af\u5883\u4e0b\u7ba1\u7406\u591a\u4e2aPython\u7248\u672c<\/h3>\n<\/p>\n<p><p>\u5728\u5f00\u53d1\u8fc7\u7a0b\u4e2d\uff0c\u4f60\u53ef\u80fd\u9700\u8981\u5728\u4e0d\u540c\u9879\u76ee\u4e2d\u4f7f\u7528\u4e0d\u540c\u7684Python\u7248\u672c\u3002\u4ee5\u4e0b\u662f\u4e00\u4e9b\u5e38\u7528\u5de5\u5177\u548c\u65b9\u6cd5\uff0c\u53ef\u4ee5\u5e2e\u52a9\u4f60\u7ba1\u7406\u591a\u4e2aPython\u7248\u672c\u3002<\/p>\n<\/p>\n<p><h4>1\u3001\u4f7f\u7528pyenv<\/h4>\n<\/p>\n<p><p>pyenv\u662f\u4e00\u4e2a\u6d41\u884c\u7684Python\u7248\u672c\u7ba1\u7406\u5de5\u5177\uff0c\u53ef\u4ee5\u8ba9\u4f60\u8f7b\u677e\u7ba1\u7406\u591a\u4e2aPython\u7248\u672c\uff0c\u5e76\u5728\u4e0d\u540c\u9879\u76ee\u4e4b\u95f4\u5207\u6362\u3002\u4ee5\u4e0b\u662f\u5177\u4f53\u6b65\u9aa4\uff1a<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u5b89\u88c5pyenv<\/strong>\uff1a<\/p>\n<\/p>\n<p><p>\u53c2\u89c1\u672c\u6587\u7b2c\u4e8c\u90e8\u5206\u4e2d\u7684\u5b89\u88c5\u6b65\u9aa4\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u5b89\u88c5\u591a\u4e2aPython\u7248\u672c<\/strong>\uff1a<\/p>\n<\/p>\n<p><p>\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\u6765\u5b89\u88c5\u4f60\u9700\u8981\u7684Python\u7248\u672c\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-shell\">pyenv install 3.x.x<\/p>\n<p>pyenv install 3.y.y<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5c06<code>3.x.x<\/code>\u548c<code>3.y.y<\/code>\u66ff\u6362\u4e3a\u4f60\u9700\u8981\u5b89\u88c5\u7684\u5177\u4f53Python\u7248\u672c\u53f7\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u8bbe\u7f6e\u5168\u5c40\u6216\u5c40\u90e8Python\u7248\u672c<\/strong>\uff1a<\/p>\n<\/p>\n<p><p>\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\u6765\u8bbe\u7f6e\u9ed8\u8ba4\u7684\u5168\u5c40Python\u7248\u672c\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-shell\">pyenv global 3.x.x<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u6216\u8005\u5728\u7279\u5b9a\u9879\u76ee\u76ee\u5f55\u4e2d\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\u6765\u8bbe\u7f6e\u5c40\u90e8Python\u7248\u672c\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-shell\">pyenv local 3.y.y<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u9a8c\u8bc1\u5b89\u88c5<\/strong>\uff1a<\/p>\n<\/p>\n<p><p>\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u4f60\u53ef\u4ee5\u901a\u8fc7\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\u6765\u9a8c\u8bc1\u662f\u5426\u6210\u529f\u5b89\u88c5\u548c\u5207\u6362\u4e86Python\u7248\u672c\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-shell\">python --version<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8be5\u547d\u4ee4\u5c06\u663e\u793a\u5f53\u524d\u4f7f\u7528\u7684Python\u7248\u672c\u53f7\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><h4>2\u3001\u4f7f\u7528virtualenv\u548cvenv<\/h4>\n<\/p>\n<p><p>virtualenv\u548cvenv\u662fPython\u81ea\u5e26\u7684\u865a\u62df\u73af\u5883\u7ba1\u7406\u5de5\u5177\uff0c\u53ef\u4ee5\u5e2e\u52a9\u4f60\u5728\u4e0d\u540c\u9879\u76ee\u4e2d\u521b\u5efa\u548c\u7ba1\u7406\u72ec\u7acb\u7684Python\u73af\u5883\u3002<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u521b\u5efa\u865a\u62df\u73af\u5883<\/strong>\uff1a<\/p>\n<\/p>\n<p><p>\u5728\u9879\u76ee\u76ee\u5f55\u4e2d\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\u6765\u521b\u5efa\u865a\u62df\u73af\u5883\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-shell\">python3 -m venv myenv<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u6216\u8005\u4f7f\u7528virtualenv\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-shell\">virtualenv myenv<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5176\u4e2d<code>myenv<\/code>\u662f\u865a\u62df\u73af\u5883\u7684\u540d\u79f0\uff0c\u4f60\u53ef\u4ee5\u6839\u636e\u9700\u8981\u8fdb\u884c\u66ff\u6362\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u6fc0\u6d3b\u865a\u62df\u73af\u5883<\/strong>\uff1a<\/p>\n<\/p>\n<p><p>\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\u6765\u6fc0\u6d3b\u865a\u62df\u73af\u5883\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-shell\">source myenv\/bin\/activate<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728Windows\u4e0a\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-shell\">myenv\\Scripts\\activate<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u5b89\u88c5\u4f9d\u8d56<\/strong>\uff1a<\/p>\n<\/p>\n<p><p>\u6fc0\u6d3b\u865a\u62df\u73af\u5883\u540e\uff0c\u4f60\u53ef\u4ee5\u50cf\u5728\u5168\u5c40\u73af\u5883\u4e2d\u4e00\u6837\u5b89\u88c5\u9879\u76ee\u6240\u9700\u7684Python\u5305\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-shell\">pip install package_name<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u9a8c\u8bc1\u5b89\u88c5<\/strong>\uff1a<\/p>\n<\/p>\n<p><p>\u4f60\u53ef\u4ee5\u901a\u8fc7\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\u6765\u9a8c\u8bc1\u662f\u5426\u6210\u529f\u5b89\u88c5\u4e86\u6240\u9700\u7684Python\u5305\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-shell\">pip list<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8be5\u547d\u4ee4\u5c06\u663e\u793a\u5f53\u524d\u865a\u62df\u73af\u5883\u4e2d\u5b89\u88c5\u7684\u6240\u6709Python\u5305\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u9000\u51fa\u865a\u62df\u73af\u5883<\/strong>\uff1a<\/p>\n<\/p>\n<p><p>\u5b8c\u6210\u5de5\u4f5c\u540e\uff0c\u4f60\u53ef\u4ee5\u901a\u8fc7\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\u6765\u9000\u51fa\u865a\u62df\u73af\u5883\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-shell\">deactivate<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<\/ol>\n<p><h3>\u4e03\u3001\u603b\u7ed3<\/h3>\n<\/p>\n<p><p>\u5347\u7ea7Python3\u7684\u65b9\u6cd5\u6709\u5f88\u591a\u79cd\uff0c\u5177\u4f53\u9009\u62e9\u54ea\u79cd\u65b9\u6cd5\u53d6\u51b3\u4e8e\u4f60\u7684\u64cd\u4f5c\u7cfb\u7edf\u548c\u9700\u6c42\u3002<strong>\u901a\u8fc7\u5305\u7ba1\u7406\u5de5\u5177\u3001\u4f7f\u7528Python\u7248\u672c\u7ba1\u7406\u5de5\u5177\u3001\u4ece\u6e90\u4ee3\u7801\u7f16\u8bd1<\/strong>\uff0c\u8fd9\u4e9b\u90fd\u662f\u5e38\u7528\u7684\u5347\u7ea7\u65b9\u6cd5\u3002\u65e0\u8bba\u4f60\u9009\u62e9\u54ea\u79cd\u65b9\u6cd5\uff0c\u90fd\u53ef\u4ee5\u6839\u636e\u5177\u4f53\u6b65\u9aa4\u8fdb\u884c\u64cd\u4f5c\uff0c\u4ee5\u786e\u4fdd\u6210\u529f\u5347\u7ea7\u5230\u4f60\u9700\u8981\u7684Python\u7248\u672c\u3002\u6b64\u5916\uff0c\u4f7f\u7528pyenv\u3001virtualenv\u548cvenv\u7b49\u5de5\u5177\uff0c\u53ef\u4ee5\u5e2e\u52a9\u4f60\u5728\u4e0d\u540c\u9879\u76ee\u4e2d\u8f7b\u677e\u7ba1\u7406\u591a\u4e2aPython\u7248\u672c\uff0c\u786e\u4fdd\u5f00\u53d1\u73af\u5883\u7684\u72ec\u7acb\u6027\u548c\u4e00\u81f4\u6027\u3002\u5e0c\u671b\u672c\u6587\u63d0\u4f9b\u7684\u4fe1\u606f\u80fd\u5e2e\u52a9\u4f60\u987a\u5229\u5b8c\u6210Python3\u7684\u5347\u7ea7\uff0c\u5e76\u5728\u5f00\u53d1\u5de5\u4f5c\u4e2d\u53d6\u5f97\u66f4\u597d\u7684\u6210\u679c\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u68c0\u67e5\u6211\u5f53\u524d\u4f7f\u7528\u7684Python\u7248\u672c\uff1f<\/strong><br \/>\u8981\u68c0\u67e5\u4f60\u5f53\u524d\u4f7f\u7528\u7684Python\u7248\u672c\uff0c\u53ef\u4ee5\u5728\u547d\u4ee4\u884c\uff08\u7ec8\u7aef\uff09\u4e2d\u8f93\u5165<code>python --version<\/code>\u6216<code>python3 --version<\/code>\u3002\u8fd9\u5c06\u663e\u793a\u5f53\u524d\u5b89\u88c5\u7684Python\u7248\u672c\u4fe1\u606f\u3002\u5982\u679c\u4f60\u7684\u7cfb\u7edf\u4e2d\u540c\u65f6\u5b89\u88c5\u4e86Python 2\u548cPython 3\uff0c\u786e\u4fdd\u4f7f\u7528<code>python3<\/code>\u547d\u4ee4\u6765\u83b7\u53d6Python 3\u7684\u7248\u672c\u3002<\/p>\n<p><strong>\u5347\u7ea7Python\u65f6\u9700\u8981\u6ce8\u610f\u54ea\u4e9b\u517c\u5bb9\u6027\u95ee\u9898\uff1f<\/strong><br \/>\u5728\u5347\u7ea7Python\u4e4b\u524d\uff0c\u9700\u8981\u8003\u8651\u5230\u4e0e\u73b0\u6709\u9879\u76ee\u7684\u517c\u5bb9\u6027\u3002\u4e00\u4e9b\u65e7\u7684\u5e93\u548c\u6846\u67b6\u53ef\u80fd\u4e0d\u652f\u6301\u6700\u65b0\u7248\u672c\u7684Python\uff0c\u56e0\u6b64\u5efa\u8bae\u5148\u67e5\u770b\u9879\u76ee\u7684\u4f9d\u8d56\u9879\uff0c\u5e76\u786e\u8ba4\u5b83\u4eec\u662f\u5426\u4e0e\u65b0\u7248\u672c\u517c\u5bb9\u3002\u53ef\u4ee5\u901a\u8fc7\u521b\u5efa\u865a\u62df\u73af\u5883\u6765\u6d4b\u8bd5\u65b0\u7248\u672c\u7684\u517c\u5bb9\u6027\uff0c\u4ee5\u907f\u514d\u5bf9\u73b0\u6709\u9879\u76ee\u9020\u6210\u5f71\u54cd\u3002<\/p>\n<p><strong>\u5728Windows\u548cLinux\u7cfb\u7edf\u4e0a\uff0c\u5982\u4f55\u5206\u522b\u5347\u7ea7Python\uff1f<\/strong><br \/>\u5728Windows\u7cfb\u7edf\u4e0a\uff0c\u53ef\u4ee5\u901a\u8fc7\u8bbf\u95eePython\u5b98\u65b9\u7f51\u7ad9\u4e0b\u8f7d\u6700\u65b0\u7248\u672c\u7684\u5b89\u88c5\u7a0b\u5e8f\uff0c\u8fd0\u884c\u5b89\u88c5\u7a0b\u5e8f\u5e76\u9009\u62e9\u201c\u5347\u7ea7\u201d\u9009\u9879\u3002\u5728Linux\u7cfb\u7edf\u4e0a\uff0c\u53ef\u4ee5\u4f7f\u7528\u5305\u7ba1\u7406\u5668\u8fdb\u884c\u5347\u7ea7\uff0c\u4f8b\u5982\u5728Ubuntu\u4e0a\u8fd0\u884c\u547d\u4ee4<code>sudo apt update<\/code>\u548c<code>sudo apt upgrade python3<\/code>\u3002\u786e\u4fdd\u5728\u5347\u7ea7\u524d\u5907\u4efd\u91cd\u8981\u7684\u9879\u76ee\u6587\u4ef6\uff0c\u4ee5\u9632\u4e0d\u6d4b\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u4e3a\u4e86\u5347\u7ea7Python3\uff0c\u4f60\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u51e0\u79cd\u65b9\u6cd5\uff1a\u901a\u8fc7\u5305\u7ba1\u7406\u5de5\u5177\u3001\u4f7f\u7528Python\u7248\u672c\u7ba1\u7406\u5de5\u5177\u3001\u4ece\u6e90\u4ee3\u7801\u7f16\u8bd1\u3002 [&hellip;]","protected":false},"author":3,"featured_media":1148105,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[37],"tags":[],"acf":[],"_links":{"self":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1148102"}],"collection":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/comments?post=1148102"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1148102\/revisions"}],"predecessor-version":[{"id":1148107,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1148102\/revisions\/1148107"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/1148105"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=1148102"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=1148102"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=1148102"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}