{"id":1152519,"date":"2025-01-13T17:26:33","date_gmt":"2025-01-13T09:26:33","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/1152519.html"},"modified":"2025-01-13T17:26:35","modified_gmt":"2025-01-13T09:26:35","slug":"%e5%a6%82%e4%bd%95%e5%90%8c%e6%97%b6%e4%bd%bf%e7%94%a8%e5%a4%9a%e4%b8%aapython","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/1152519.html","title":{"rendered":"\u5982\u4f55\u540c\u65f6\u4f7f\u7528\u591a\u4e2apython"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/25182446\/f480f7d7-bcad-45f3-8e95-6a489e33a77b.webp\" alt=\"\u5982\u4f55\u540c\u65f6\u4f7f\u7528\u591a\u4e2apython\" \/><\/p>\n<p><p> <strong>\u4f7f\u7528\u865a\u62df\u73af\u5883\u3001\u5229\u7528\u4e0d\u540c\u7248\u672c\u7684Python\u89e3\u91ca\u5668\u3001\u4f7f\u7528\u5bb9\u5668\u5316\u6280\u672f\u5982Docker<\/strong>\uff0c\u53ef\u4ee5\u5b9e\u73b0\u540c\u65f6\u4f7f\u7528\u591a\u4e2aPython\u7248\u672c\u6216\u73af\u5883\u3002<strong>\u865a\u62df\u73af\u5883<\/strong> \u662f\u4e00\u4e2a\u8f7b\u91cf\u7ea7\u7684\u89e3\u51b3\u65b9\u6848\uff0c\u5b83\u5141\u8bb8\u5728\u540c\u4e00\u7cfb\u7edf\u4e0a\u521b\u5efa\u591a\u4e2a\u72ec\u7acb\u7684Python\u73af\u5883\u3002\u901a\u8fc7\u865a\u62df\u73af\u5883\uff0c\u4f60\u53ef\u4ee5\u5728\u9879\u76ee\u4e4b\u95f4\u9694\u79bb\u4f9d\u8d56\u9879\uff0c\u4ece\u800c\u907f\u514d\u7248\u672c\u51b2\u7a81\u548c\u4f9d\u8d56\u95ee\u9898\u3002\u8fd9\u662f\u5b9e\u73b0\u540c\u65f6\u4f7f\u7528\u591a\u4e2aPython\u7248\u672c\u6216\u73af\u5883\u7684\u6700\u5e38\u89c1\u548c\u6700\u63a8\u8350\u7684\u65b9\u6cd5\u3002<\/p>\n<\/p>\n<p><p>\u521b\u5efa\u865a\u62df\u73af\u5883\u7684\u65b9\u6cd5\u5982\u4e0b\uff1a<\/p>\n<\/p>\n<ol>\n<li>\u5b89\u88c5 <code>virtualenv<\/code>\uff1a\u9996\u5148\u9700\u8981\u5b89\u88c5\u865a\u62df\u73af\u5883\u5de5\u5177\uff0c\u53ef\u4ee5\u901a\u8fc7 pip \u8fdb\u884c\u5b89\u88c5\u3002\n<pre><code class=\"language-bash\">pip install virtualenv<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\u521b\u5efa\u865a\u62df\u73af\u5883\uff1a\u5728\u9879\u76ee\u76ee\u5f55\u4e2d\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u865a\u62df\u73af\u5883\u3002\n<pre><code class=\"language-bash\">virtualenv venv<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p>\u5176\u4e2d <code>venv<\/code> \u662f\u865a\u62df\u73af\u5883\u7684\u540d\u79f0\uff0c\u4f60\u53ef\u4ee5\u6839\u636e\u9700\u8981\u66ff\u6362\u4e3a\u5176\u4ed6\u540d\u79f0\u3002<\/li>\n<\/p>\n<li>\u6fc0\u6d3b\u865a\u62df\u73af\u5883\uff1a\u6839\u636e\u64cd\u4f5c\u7cfb\u7edf\u7684\u4e0d\u540c\uff0c\u6fc0\u6d3b\u865a\u62df\u73af\u5883\u7684\u547d\u4ee4\u6709\u6240\u4e0d\u540c\u3002\n<ul>\n<li>Windows\uff1a\n<pre><code class=\"language-bash\">.\\venv\\Scripts\\activate<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>macOS \u548c Linux\uff1a\n<pre><code class=\"language-bash\">source venv\/bin\/activate<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<p><p>\u6fc0\u6d3b\u865a\u62df\u73af\u5883\u540e\uff0c\u4f60\u53ef\u4ee5\u5b89\u88c5\u7279\u5b9a\u7248\u672c\u7684Python\u5305\uff0c\u5e76\u5728\u8be5\u73af\u5883\u4e2d\u8fd0\u884cPython\u7a0b\u5e8f\uff0c\u800c\u4e0d\u4f1a\u5f71\u54cd\u5230\u7cfb\u7edf\u7684\u5176\u4ed6Python\u73af\u5883\u3002\u8fd9\u79cd\u65b9\u6cd5\u7279\u522b\u9002\u7528\u4e8e\u591a\u4e2a\u9879\u76ee\u9700\u8981\u4e0d\u540c\u7248\u672c\u7684\u4f9d\u8d56\u5305\u6216Python\u89e3\u91ca\u5668\u7684\u60c5\u51b5\u3002<\/p>\n<\/p>\n<p><h2>\u4e00\u3001\u4f7f\u7528\u865a\u62df\u73af\u5883<\/h2>\n<\/p>\n<p><h3>\u865a\u62df\u73af\u5883\u7684\u521b\u5efa\u4e0e\u7ba1\u7406<\/h3>\n<\/p>\n<p><p>\u865a\u62df\u73af\u5883\u662fPython\u4e2d\u4e00\u4e2a\u975e\u5e38\u5f3a\u5927\u7684\u5de5\u5177\uff0c\u80fd\u591f\u5e2e\u52a9\u5f00\u53d1\u8005\u5728\u540c\u4e00\u53f0\u673a\u5668\u4e0a\u8fd0\u884c\u4e0d\u540c\u7684Python\u7248\u672c\u548c\u4f9d\u8d56\u5305\u3002\u901a\u8fc7\u4f7f\u7528\u865a\u62df\u73af\u5883\uff0c\u4f60\u53ef\u4ee5\u907f\u514d\u5305\u548c\u7248\u672c\u4e4b\u95f4\u7684\u51b2\u7a81\uff0c\u8fd9\u5bf9\u4e8e\u591a\u4e2a\u9879\u76ee\u7684\u5f00\u53d1\u5c24\u5176\u91cd\u8981\u3002<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u521b\u5efa\u865a\u62df\u73af\u5883<\/strong>\uff1a<\/p>\n<p>\u521b\u5efa\u865a\u62df\u73af\u5883\u7684\u5de5\u5177\u6709\u5f88\u591a\uff0c\u6700\u5e38\u7528\u7684\u5305\u62ec<code>virtualenv<\/code>\u548c<code>venv<\/code>\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\"># \u4f7f\u7528virtualenv\u521b\u5efa\u865a\u62df\u73af\u5883<\/p>\n<p>pip install virtualenv<\/p>\n<p>virtualenv myenv<\/p>\n<h2><strong>\u4f7f\u7528venv\u521b\u5efa\u865a\u62df\u73af\u5883<\/strong><\/h2>\n<p>python3 -m venv myenv<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u6fc0\u6d3b\u865a\u62df\u73af\u5883<\/strong>\uff1a<\/p>\n<p>\u6fc0\u6d3b\u865a\u62df\u73af\u5883\u7684\u547d\u4ee4\u6839\u636e\u64cd\u4f5c\u7cfb\u7edf\u7684\u4e0d\u540c\u800c\u6709\u6240\u533a\u522b\u3002<\/p>\n<\/p>\n<ul>\n<li>\u5728Windows\u4e0a\uff1a\n<pre><code class=\"language-bash\">myenv\\Scripts\\activate<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\u5728macOS\u548cLinux\u4e0a\uff1a\n<pre><code class=\"language-bash\">source myenv\/bin\/activate<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>\u5b89\u88c5\u4f9d\u8d56\u5305<\/strong>\uff1a<\/p>\n<p>\u6fc0\u6d3b\u865a\u62df\u73af\u5883\u540e\uff0c\u4f60\u53ef\u4ee5\u4f7f\u7528pip\u5b89\u88c5\u7279\u5b9a\u7248\u672c\u7684\u4f9d\u8d56\u5305\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip install numpy==1.18.5<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u9000\u51fa\u865a\u62df\u73af\u5883<\/strong>\uff1a<\/p>\n<p>\u5f53\u4f60\u5b8c\u6210\u5de5\u4f5c\u540e\uff0c\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4\u9000\u51fa\u865a\u62df\u73af\u5883\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">deactivate<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<\/ol>\n<p><h3>\u7ba1\u7406\u591a\u4e2a\u865a\u62df\u73af\u5883<\/h3>\n<\/p>\n<p><p>\u7ba1\u7406\u591a\u4e2a\u865a\u62df\u73af\u5883\u53ef\u80fd\u4f1a\u53d8\u5f97\u590d\u6742\uff0c\u56e0\u6b64\u6709\u4e00\u4e9b\u5de5\u5177\u53ef\u4ee5\u5e2e\u52a9\u4f60\u66f4\u597d\u5730\u7ba1\u7406\u8fd9\u4e9b\u73af\u5883\u3002<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>virtualenvwrapper<\/strong>\uff1a<\/p>\n<p><code>virtualenvwrapper<\/code>\u662f\u4e00\u4e2a\u7528\u4e8e\u7b80\u5316<code>virtualenv<\/code>\u7ba1\u7406\u7684\u5de5\u5177\u3002<\/p>\n<\/p>\n<p><p>\u5b89\u88c5<code>virtualenvwrapper<\/code>\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip install virtualenvwrapper<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u914d\u7f6e<code>virtualenvwrapper<\/code>\uff08\u5728\u4f60\u7684shell\u914d\u7f6e\u6587\u4ef6\u4e2d\uff0c\u4f8b\u5982<code>.bashrc<\/code>\u6216<code>.zshrc<\/code>\uff09\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">export WORKON_HOME=$HOME\/.virtualenvs<\/p>\n<p>source \/usr\/local\/bin\/virtualenvwrapper.sh<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u4f7f\u7528<code>virtualenvwrapper<\/code>\u521b\u5efa\u548c\u7ba1\u7406\u865a\u62df\u73af\u5883\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">mkvirtualenv myproject<\/p>\n<p>workon myproject<\/p>\n<p>deactivate<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>pipenv<\/strong>\uff1a<\/p>\n<p><code>pipenv<\/code>\u662f\u53e6\u4e00\u4e2a\u7528\u4e8e\u7ba1\u7406\u9879\u76ee\u4f9d\u8d56\u548c\u865a\u62df\u73af\u5883\u7684\u5de5\u5177\u3002<\/p>\n<\/p>\n<p><p>\u5b89\u88c5<code>pipenv<\/code>\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip install pipenv<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u4f7f\u7528<code>pipenv<\/code>\u521b\u5efa\u548c\u7ba1\u7406\u865a\u62df\u73af\u5883\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pipenv install requests<\/p>\n<p>pipenv shell<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<\/ol>\n<p><h2>\u4e8c\u3001\u5229\u7528\u4e0d\u540c\u7248\u672c\u7684Python\u89e3\u91ca\u5668<\/h2>\n<\/p>\n<p><p>\u5728\u540c\u4e00\u53f0\u673a\u5668\u4e0a\u5b89\u88c5\u591a\u4e2a\u7248\u672c\u7684Python\u89e3\u91ca\u5668\uff0c\u53ef\u4ee5\u5e2e\u52a9\u4f60\u5728\u4e0d\u540c\u7684\u9879\u76ee\u4e2d\u4f7f\u7528\u4e0d\u540c\u7684Python\u7248\u672c\u3002<\/p>\n<\/p>\n<p><h3>\u5b89\u88c5\u591a\u4e2aPython\u7248\u672c<\/h3>\n<\/p>\n<ol>\n<li>\n<p><strong>\u4f7f\u7528\u5305\u7ba1\u7406\u5668<\/strong>\uff1a<\/p>\n<\/p>\n<ul>\n<li>\u5728Windows\u4e0a\uff0c\u53ef\u4ee5\u4ecePython\u5b98\u65b9\u7f51\u7ad9\u4e0b\u8f7d\u5e76\u5b89\u88c5\u4e0d\u540c\u7248\u672c\u7684Python\u3002<\/li>\n<li>\u5728macOS\u4e0a\uff0c\u53ef\u4ee5\u4f7f\u7528<code>brew<\/code>\u5b89\u88c5\u4e0d\u540c\u7248\u672c\u7684Python\u3002\n<pre><code class=\"language-bash\">brew install python@3.8<\/p>\n<p>brew install python@3.9<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\u5728Linux\u4e0a\uff0c\u53ef\u4ee5\u4f7f\u7528\u5305\u7ba1\u7406\u5668\uff08\u5982<code>apt<\/code>\u6216<code>yum<\/code>\uff09\u5b89\u88c5\u4e0d\u540c\u7248\u672c\u7684Python\u3002\n<pre><code class=\"language-bash\">sudo apt-get install python3.8<\/p>\n<p>sudo apt-get install python3.9<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>\u4f7f\u7528<code>pyenv<\/code><\/strong>\uff1a<\/p>\n<p><code>pyenv<\/code>\u662f\u4e00\u4e2a\u7528\u4e8e\u7ba1\u7406\u591a\u4e2aPython\u7248\u672c\u7684\u5de5\u5177\uff0c\u652f\u6301\u5728\u540c\u4e00\u53f0\u673a\u5668\u4e0a\u8f7b\u677e\u5b89\u88c5\u548c\u5207\u6362\u4e0d\u540c\u7248\u672c\u7684Python\u3002<\/p>\n<\/p>\n<p><p>\u5b89\u88c5<code>pyenv<\/code>\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">curl https:\/\/pyenv.run | bash<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u914d\u7f6e<code>pyenv<\/code>\uff08\u5728\u4f60\u7684shell\u914d\u7f6e\u6587\u4ef6\u4e2d\uff0c\u4f8b\u5982<code>.bashrc<\/code>\u6216<code>.zshrc<\/code>\uff09\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">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>\u4f7f\u7528<code>pyenv<\/code>\u5b89\u88c5\u548c\u7ba1\u7406Python\u7248\u672c\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pyenv install 3.8.0<\/p>\n<p>pyenv install 3.9.0<\/p>\n<p>pyenv global 3.8.0<\/p>\n<p>pyenv local 3.9.0<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<\/ol>\n<p><h3>\u5207\u6362Python\u7248\u672c<\/h3>\n<\/p>\n<p><p>\u4f7f\u7528<code>pyenv<\/code>\u6216\u5176\u4ed6\u5de5\u5177\u5207\u6362Python\u7248\u672c\uff0c\u53ef\u4ee5\u786e\u4fdd\u5728\u4e0d\u540c\u7684\u9879\u76ee\u4e2d\u4f7f\u7528\u5408\u9002\u7684Python\u89e3\u91ca\u5668\u3002<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u5168\u5c40\u8bbe\u7f6ePython\u7248\u672c<\/strong>\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pyenv global 3.8.0<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u9879\u76ee\u672c\u5730\u8bbe\u7f6ePython\u7248\u672c<\/strong>\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pyenv local 3.9.0<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u4e34\u65f6\u5207\u6362Python\u7248\u672c<\/strong>\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pyenv shell 3.8.0<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<\/ol>\n<p><h2>\u4e09\u3001\u4f7f\u7528\u5bb9\u5668\u5316\u6280\u672f\u5982Docker<\/h2>\n<\/p>\n<p><p>Docker\u662f\u4e00\u79cd\u5bb9\u5668\u5316\u6280\u672f\uff0c\u80fd\u591f\u5e2e\u52a9\u4f60\u5728\u9694\u79bb\u7684\u73af\u5883\u4e2d\u8fd0\u884c\u5e94\u7528\u7a0b\u5e8f\uff0c\u5305\u62ecPython\u5e94\u7528\u3002\u8fd9\u5bf9\u4e8e\u9700\u8981\u5728\u4e0d\u540c\u7684\u73af\u5883\u4e2d\u8fd0\u884c\u4e0d\u540c\u7248\u672c\u7684Python\u5e94\u7528\u975e\u5e38\u6709\u7528\u3002<\/p>\n<\/p>\n<p><h3>Docker\u7684\u57fa\u672c\u6982\u5ff5<\/h3>\n<\/p>\n<p><p>Docker\u4f7f\u7528\u5bb9\u5668\u6765\u5c01\u88c5\u5e94\u7528\u7a0b\u5e8f\u53ca\u5176\u4f9d\u8d56\u9879\uff0c\u4f7f\u5176\u80fd\u591f\u5728\u4efb\u4f55\u73af\u5883\u4e2d\u4e00\u81f4\u5730\u8fd0\u884c\u3002\u6bcf\u4e2a\u5bb9\u5668\u90fd\u662f\u4e00\u4e2a\u72ec\u7acb\u7684\u3001\u8f7b\u91cf\u7ea7\u7684\u73af\u5883\uff0c\u5305\u542b\u5e94\u7528\u7a0b\u5e8f\u6240\u9700\u7684\u6240\u6709\u4f9d\u8d56\u9879\u3002<\/p>\n<\/p>\n<p><h3>\u5b89\u88c5Docker<\/h3>\n<\/p>\n<ol>\n<li>\n<p><strong>\u5728Windows\u4e0a\u5b89\u88c5Docker<\/strong>\uff1a<\/p>\n<\/p>\n<ul>\n<li>\u4e0b\u8f7d\u5e76\u5b89\u88c5Docker Desktop for Windows\uff1a<a href=\"https:\/\/www.docker.com\/products\/docker-desktop\">https:\/\/www.docker.com\/products\/docker-desktop<\/a><\/li>\n<li>\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u542f\u52a8Docker Desktop\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>\u5728macOS\u4e0a\u5b89\u88c5Docker<\/strong>\uff1a<\/p>\n<\/p>\n<ul>\n<li>\u4e0b\u8f7d\u5e76\u5b89\u88c5Docker Desktop for Mac\uff1a<a href=\"https:\/\/www.docker.com\/products\/docker-desktop\">https:\/\/www.docker.com\/products\/docker-desktop<\/a><\/li>\n<li>\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u542f\u52a8Docker Desktop\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>\u5728Linux\u4e0a\u5b89\u88c5Docker<\/strong>\uff1a<\/p>\n<\/p>\n<ul>\n<li>\u4f7f\u7528\u5305\u7ba1\u7406\u5668\u5b89\u88c5Docker\u3002\n<pre><code class=\"language-bash\">sudo apt-get update<\/p>\n<p>sudo apt-get install docker-ce docker-ce-cli cont<a href=\"https:\/\/docs.pingcode.com\/blog\/59162.html\" target=\"_blank\">AI<\/a>nerd.io<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<p><h3>\u4f7f\u7528Docker\u521b\u5efaPython\u5bb9\u5668<\/h3>\n<\/p>\n<ol>\n<li>\n<p><strong>\u521b\u5efaDockerfile<\/strong>\uff1a<\/p>\n<p>Dockerfile\u662f\u4e00\u4e2a\u6587\u672c\u6587\u4ef6\uff0c\u5305\u542b\u6784\u5efaDocker\u955c\u50cf\u7684\u6240\u6709\u6307\u4ee4\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-dockerfile\"># \u4f7f\u7528\u5b98\u65b9\u7684Python\u57fa\u7840\u955c\u50cf<\/p>\n<p>FROM python:3.8-slim<\/p>\n<h2><strong>\u8bbe\u7f6e\u5de5\u4f5c\u76ee\u5f55<\/strong><\/h2>\n<p>WORKDIR \/app<\/p>\n<h2><strong>\u590d\u5236\u5f53\u524d\u76ee\u5f55\u7684\u5185\u5bb9\u5230\u5bb9\u5668\u4e2d\u7684\/app\u76ee\u5f55<\/strong><\/h2>\n<p>COPY . \/app<\/p>\n<h2><strong>\u5b89\u88c5\u4f9d\u8d56<\/strong><\/h2>\n<p>RUN pip install --no-cache-dir -r requirements.txt<\/p>\n<h2><strong>\u8fd0\u884c\u5e94\u7528\u7a0b\u5e8f<\/strong><\/h2>\n<p>CMD [&quot;python&quot;, &quot;app.py&quot;]<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u6784\u5efaDocker\u955c\u50cf<\/strong>\uff1a<\/p>\n<p>\u4f7f\u7528Dockerfile\u6784\u5efaDocker\u955c\u50cf\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">docker build -t my-python-app .<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u8fd0\u884cDocker\u5bb9\u5668<\/strong>\uff1a<\/p>\n<p>\u8fd0\u884cDocker\u5bb9\u5668\uff0c\u5e76\u5728\u5bb9\u5668\u4e2d\u8fd0\u884cPython\u5e94\u7528\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">docker run -it --rm --name my-running-app my-python-app<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<\/ol>\n<p><h3>\u7ba1\u7406\u591a\u4e2aDocker\u5bb9\u5668<\/h3>\n<\/p>\n<p><p>Docker\u63d0\u4f9b\u4e86\u5f3a\u5927\u7684\u5de5\u5177\u6765\u7ba1\u7406\u591a\u4e2a\u5bb9\u5668\uff0c\u5305\u62ecDocker Compose\u3002<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u5b89\u88c5Docker Compose<\/strong>\uff1a<\/p>\n<p>Docker Compose\u662f\u4e00\u4e2a\u7528\u4e8e\u5b9a\u4e49\u548c\u8fd0\u884c\u591a\u5bb9\u5668Docker\u5e94\u7528\u7684\u5de5\u5177\u3002<\/p>\n<\/p>\n<ul>\n<li>\u5728Windows\u548cmacOS\u4e0a\uff0cDocker Desktop\u5df2\u7ecf\u5305\u542bDocker Compose\u3002<\/li>\n<li>\u5728Linux\u4e0a\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u5b89\u88c5Docker Compose\u3002\n<pre><code class=\"language-bash\">sudo curl -L &quot;https:\/\/github.com\/docker\/compose\/releases\/download\/1.29.2\/docker-compose-$(uname -s)-$(uname -m)&quot; -o \/usr\/local\/bin\/docker-compose<\/p>\n<p>sudo chmod +x \/usr\/local\/bin\/docker-compose<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>\u521b\u5efadocker-compose.yml\u6587\u4ef6<\/strong>\uff1a<\/p>\n<p>\u5b9a\u4e49\u591a\u4e2a\u670d\u52a1\u7684\u914d\u7f6e\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-yaml\">version: &#39;3&#39;<\/p>\n<p>services:<\/p>\n<p>  web:<\/p>\n<p>    image: my-python-app<\/p>\n<p>    build: .<\/p>\n<p>    ports:<\/p>\n<p>      - &quot;5000:5000&quot;<\/p>\n<p>  db:<\/p>\n<p>    image: postgres:latest<\/p>\n<p>    environment:<\/p>\n<p>      POSTGRES_PASSWORD: example<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u4f7f\u7528Docker Compose\u8fd0\u884c\u591a\u4e2a\u5bb9\u5668<\/strong>\uff1a<\/p>\n<p>\u4f7f\u7528Docker Compose\u7ba1\u7406\u548c\u8fd0\u884c\u591a\u4e2a\u5bb9\u5668\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">docker-compose up<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<\/ol>\n<p><h2>\u56db\u3001\u4f7f\u7528\u865a\u62df\u673a\u6216\u591a\u64cd\u4f5c\u7cfb\u7edf<\/h2>\n<\/p>\n<p><p>\u9664\u4e86\u865a\u62df\u73af\u5883\u548cDocker\uff0c\u4f7f\u7528\u865a\u62df\u673a\u6216\u591a\u64cd\u4f5c\u7cfb\u7edf\u4e5f\u662f\u4e00\u79cd\u5b9e\u73b0\u540c\u65f6\u4f7f\u7528\u591a\u4e2aPython\u7248\u672c\u7684\u65b9\u6cd5\u3002<\/p>\n<\/p>\n<p><h3>\u865a\u62df\u673a\u7684\u57fa\u672c\u6982\u5ff5<\/h3>\n<\/p>\n<p><p>\u865a\u62df\u673a\uff08VM\uff09\u662f\u4e00\u79cd\u8f6f\u4ef6\u6a21\u62df\u7684\u8ba1\u7b97\u673a\u7cfb\u7edf\uff0c\u53ef\u4ee5\u5728\u7269\u7406\u673a\u5668\u4e0a\u8fd0\u884c\u591a\u4e2a\u72ec\u7acb\u7684\u64cd\u4f5c\u7cfb\u7edf\u3002\u6bcf\u4e2a\u865a\u62df\u673a\u90fd\u6709\u81ea\u5df1\u7684\u64cd\u4f5c\u7cfb\u7edf\u3001\u5e94\u7528\u7a0b\u5e8f\u548c\u8d44\u6e90\uff0c\u53ef\u4ee5\u76f8\u4e92\u72ec\u7acb\u5730\u8fd0\u884c\u3002<\/p>\n<\/p>\n<p><h3>\u865a\u62df\u673a\u7684\u5b89\u88c5\u4e0e\u914d\u7f6e<\/h3>\n<\/p>\n<ol>\n<li>\n<p><strong>\u9009\u62e9\u865a\u62df\u673a\u8f6f\u4ef6<\/strong>\uff1a<\/p>\n<\/p>\n<ul>\n<li>VirtualBox\uff1a<a href=\"https:\/\/www.virtualbox.org\/\">https:\/\/www.virtualbox.org\/<\/a><\/li>\n<li>VMware\uff1a<a href=\"https:\/\/www.vmware.com\/\">https:\/\/www.vmware.com\/<\/a><\/li>\n<li>Hyper-V\uff08Windows\u5185\u7f6e\u865a\u62df\u5316\u5de5\u5177\uff09<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>\u5b89\u88c5\u865a\u62df\u673a\u8f6f\u4ef6<\/strong>\uff1a<\/p>\n<p>\u4e0b\u8f7d\u5e76\u5b89\u88c5\u6240\u9009\u7684\u865a\u62df\u673a\u8f6f\u4ef6\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u521b\u5efa\u865a\u62df\u673a<\/strong>\uff1a<\/p>\n<p>\u4f7f\u7528\u865a\u62df\u673a\u8f6f\u4ef6\u521b\u5efa\u65b0\u7684\u865a\u62df\u673a\uff0c\u5e76\u5b89\u88c5\u6240\u9700\u7684\u64cd\u4f5c\u7cfb\u7edf\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><h3>\u5728\u865a\u62df\u673a\u4e0a\u5b89\u88c5\u591a\u4e2aPython\u7248\u672c<\/h3>\n<\/p>\n<p><p>\u5728\u865a\u62df\u673a\u4e2d\uff0c\u4f60\u53ef\u4ee5\u5b89\u88c5\u4e0d\u540c\u7248\u672c\u7684Python\uff0c\u5e76\u6839\u636e\u9700\u8981\u5728\u4e0d\u540c\u7684\u865a\u62df\u673a\u4e0a\u8fd0\u884c\u4e0d\u540c\u7684Python\u73af\u5883\u3002<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u4e0b\u8f7dPython\u5b89\u88c5\u5305<\/strong>\uff1a<\/p>\n<p>\u4ecePython\u5b98\u65b9\u7f51\u7ad9\u4e0b\u8f7d\u4e0d\u540c\u7248\u672c\u7684Python\u5b89\u88c5\u5305\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u5b89\u88c5Python<\/strong>\uff1a<\/p>\n<p>\u5728\u865a\u62df\u673a\u4e2d\u5b89\u88c5\u6240\u9700\u7684Python\u7248\u672c\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u914d\u7f6e\u73af\u5883\u53d8\u91cf<\/strong>\uff1a<\/p>\n<p>\u6839\u636e\u9700\u8981\u914d\u7f6e\u73af\u5883\u53d8\u91cf\uff0c\u4f7f\u865a\u62df\u673a\u80fd\u591f\u8bc6\u522b\u548c\u4f7f\u7528\u4e0d\u540c\u7248\u672c\u7684Python\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><h3>\u4f7f\u7528\u591a\u64cd\u4f5c\u7cfb\u7edf<\/h3>\n<\/p>\n<p><p>\u5728\u7269\u7406\u673a\u5668\u4e0a\u5b89\u88c5\u591a\u4e2a\u64cd\u4f5c\u7cfb\u7edf\uff08\u5982Windows\u3001macOS\u3001Linux\uff09\uff0c\u5e76\u5728\u4e0d\u540c\u7684\u64cd\u4f5c\u7cfb\u7edf\u4e0a\u5b89\u88c5\u548c\u8fd0\u884c\u4e0d\u540c\u7248\u672c\u7684Python\u3002\u8fd9\u79cd\u65b9\u6cd5\u9002\u7528\u4e8e\u9700\u8981\u5728\u4e0d\u540c\u64cd\u4f5c\u7cfb\u7edf\u4e0a\u8fdb\u884c\u5f00\u53d1\u548c\u6d4b\u8bd5\u7684\u60c5\u51b5\u3002<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u5b89\u88c5\u591a\u64cd\u4f5c\u7cfb\u7edf<\/strong>\uff1a<\/p>\n<p>\u4f7f\u7528\u53cc\u542f\u52a8\u6216\u591a\u542f\u52a8\u914d\u7f6e\uff0c\u5728\u7269\u7406\u673a\u5668\u4e0a\u5b89\u88c5\u591a\u4e2a\u64cd\u4f5c\u7cfb\u7edf\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u5207\u6362\u64cd\u4f5c\u7cfb\u7edf<\/strong>\uff1a<\/p>\n<p>\u6839\u636e\u9700\u8981\u5207\u6362\u5230\u4e0d\u540c\u7684\u64cd\u4f5c\u7cfb\u7edf\uff0c\u5e76\u5728\u6bcf\u4e2a\u64cd\u4f5c\u7cfb\u7edf\u4e0a\u5b89\u88c5\u548c\u914d\u7f6e\u6240\u9700\u7684Python\u7248\u672c\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><h2>\u4e94\u3001\u4f7f\u7528Anaconda\u548cConda\u73af\u5883<\/h2>\n<\/p>\n<p><p>Anaconda\u662f\u4e00\u4e2a\u7528\u4e8e\u79d1\u5b66\u8ba1\u7b97\u548c\u6570\u636e\u5206\u6790\u7684Python\u53d1\u884c\u7248\uff0c\u5305\u542b\u4e86\u5927\u91cf\u7684\u79d1\u5b66\u8ba1\u7b97\u5e93\u548c\u5de5\u5177\u3002Conda\u662fAnaconda\u4e2d\u7528\u4e8e\u7ba1\u7406\u5305\u548c\u73af\u5883\u7684\u5de5\u5177\uff0c\u53ef\u4ee5\u5e2e\u52a9\u4f60\u5728\u540c\u4e00\u53f0\u673a\u5668\u4e0a\u7ba1\u7406\u591a\u4e2aPython\u73af\u5883\u3002<\/p>\n<\/p>\n<p><h3>\u5b89\u88c5Anaconda<\/h3>\n<\/p>\n<ol>\n<li>\n<p><strong>\u4e0b\u8f7dAnaconda<\/strong>\uff1a<\/p>\n<p>\u4eceAnaconda\u5b98\u65b9\u7f51\u7ad9\u4e0b\u8f7d\u9002\u7528\u4e8e\u4f60\u64cd\u4f5c\u7cfb\u7edf\u7684\u5b89\u88c5\u5305\uff1a<a href=\"https:\/\/www.anaconda.com\/\">https:\/\/www.anaconda.com\/<\/a><\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u5b89\u88c5Anaconda<\/strong>\uff1a<\/p>\n<p>\u8fd0\u884c\u5b89\u88c5\u5305\uff0c\u5e76\u6309\u7167\u63d0\u793a\u5b8c\u6210\u5b89\u88c5\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><h3>\u4f7f\u7528Conda\u521b\u5efa\u548c\u7ba1\u7406\u73af\u5883<\/h3>\n<\/p>\n<p><p>Conda\u662f\u4e00\u4e2a\u5f3a\u5927\u7684\u5305\u548c\u73af\u5883\u7ba1\u7406\u5de5\u5177\uff0c\u53ef\u4ee5\u5e2e\u52a9\u4f60\u521b\u5efa\u548c\u7ba1\u7406\u591a\u4e2aPython\u73af\u5883\u3002<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u521b\u5efaConda\u73af\u5883<\/strong>\uff1a<\/p>\n<p>\u4f7f\u7528Conda\u521b\u5efa\u65b0\u7684Python\u73af\u5883\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">conda create --name myenv python=3.8<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u6fc0\u6d3bConda\u73af\u5883<\/strong>\uff1a<\/p>\n<p>\u6fc0\u6d3bConda\u73af\u5883\uff0c\u5e76\u5728\u8be5\u73af\u5883\u4e2d\u8fd0\u884cPython\u7a0b\u5e8f\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">conda activate myenv<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u5b89\u88c5\u4f9d\u8d56\u5305<\/strong>\uff1a<\/p>\n<p>\u4f7f\u7528Conda\u5b89\u88c5\u6240\u9700\u7684\u4f9d\u8d56\u5305\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">conda install numpy pandas<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u9000\u51faConda\u73af\u5883<\/strong>\uff1a<\/p>\n<p>\u5f53\u4f60\u5b8c\u6210\u5de5\u4f5c\u540e\uff0c\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4\u9000\u51faConda\u73af\u5883\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">conda deactivate<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<\/ol>\n<p><h3>\u7ba1\u7406\u591a\u4e2aConda\u73af\u5883<\/h3>\n<\/p>\n<ol>\n<li>\n<p><strong>\u5217\u51faConda\u73af\u5883<\/strong>\uff1a<\/p>\n<p>\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u5217\u51fa\u6240\u6709Conda\u73af\u5883\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">conda env list<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u5220\u9664Conda\u73af\u5883<\/strong>\uff1a<\/p>\n<p>\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u5220\u9664\u6307\u5b9a\u7684Conda\u73af\u5883\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">conda remove --name myenv --all<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u514b\u9686Conda\u73af\u5883<\/strong>\uff1a<\/p>\n<p>\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u514b\u9686\u73b0\u6709\u7684Conda\u73af\u5883\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">conda create --name newenv --clone myenv<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<\/ol>\n<p><h2>\u516d\u3001\u4f7f\u7528Jupyter Notebook\u548cJupyterLab<\/h2>\n<\/p>\n<p><p>Jupyter Notebook\u548cJupyterLab\u662f\u7528\u4e8e\u4ea4\u4e92\u5f0f\u7f16\u7a0b\u548c\u6570\u636e\u5206\u6790\u7684\u5de5\u5177\uff0c\u652f\u6301\u591a\u79cd\u7f16\u7a0b\u8bed\u8a00\uff0c\u5305\u62ecPython\u3002\u901a\u8fc7\u4f7f\u7528Jupyter Notebook\u548cJupyterLab\uff0c\u4f60\u53ef\u4ee5\u5728\u540c\u4e00\u53f0\u673a\u5668\u4e0a\u8fd0\u884c\u591a\u4e2aPython\u5185\u6838\uff0c\u5b9e\u73b0\u540c\u65f6\u4f7f\u7528\u591a\u4e2aPython\u7248\u672c\u3002<\/p>\n<\/p>\n<p><h3>\u5b89\u88c5Jupyter Notebook\u548cJupyterLab<\/h3>\n<\/p>\n<ol>\n<li>\n<p><strong>\u5b89\u88c5Jupyter Notebook<\/strong>\uff1a<\/p>\n<p>\u4f7f\u7528pip\u6216Conda\u5b89\u88c5Jupyter Notebook\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip install notebook<\/p>\n<h2><strong>\u6216\u8005<\/strong><\/h2>\n<p>conda install notebook<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u5b89\u88c5JupyterLab<\/strong>\uff1a<\/p>\n<p>\u4f7f\u7528pip\u6216Conda\u5b89\u88c5JupyterLab\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip install jupyterlab<\/p>\n<h2><strong>\u6216\u8005<\/strong><\/h2>\n<p>conda install jupyterlab<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<\/ol>\n<p><h3>\u521b\u5efa\u548c\u7ba1\u7406Jupyter\u5185\u6838<\/h3>\n<\/p>\n<p><p>Jupyter\u5185\u6838\u662fJupyter Notebook\u548cJupyterLab\u4e2d\u7528\u4e8e\u6267\u884c\u4ee3\u7801\u7684\u540e\u7aef\u3002\u901a\u8fc7\u521b\u5efa\u548c\u7ba1\u7406\u591a\u4e2aJupyter\u5185\u6838\uff0c\u4f60\u53ef\u4ee5\u5728\u540c\u4e00\u53f0\u673a\u5668\u4e0a\u8fd0\u884c\u4e0d\u540c\u7248\u672c\u7684Python\u3002<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u5b89\u88c5IPython\u5185\u6838<\/strong>\uff1a<\/p>\n<p>\u4f7f\u7528pip\u6216Conda\u5b89\u88c5IPython\u5185\u6838\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip install ipykernel<\/p>\n<h2><strong>\u6216\u8005<\/strong><\/h2>\n<p>conda install ipykernel<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u521b\u5efa\u65b0\u7684Jupyter\u5185\u6838<\/strong>\uff1a<\/p>\n<p>\u4f7f\u7528IPython\u5185\u6838\u521b\u5efa\u65b0\u7684Jupyter\u5185\u6838\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">python -m ipykernel install --user --name myenv --display-name &quot;Python 3.8 (myenv)&quot;<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u5207\u6362Jupyter\u5185\u6838<\/strong>\uff1a<\/p>\n<p>\u5728Jupyter Notebook\u6216JupyterLab\u4e2d\uff0c\u53ef\u4ee5\u901a\u8fc7\u5185\u6838\u83dc\u5355\u5207\u6362\u5230\u4e0d\u540c\u7684Jupyter\u5185\u6838\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u5220\u9664Jupyter\u5185\u6838<\/strong>\uff1a<\/p>\n<p>\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u5220\u9664\u6307\u5b9a\u7684Jupyter\u5185\u6838\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">jupyter kernelspec uninstall myenv<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<\/ol>\n<p><h2>\u4e03\u3001\u4f7f\u7528\u8fdc\u7a0b\u670d\u52a1\u5668\u548c\u4e91\u670d\u52a1<\/h2>\n<\/p>\n<p><p>\u4f7f\u7528\u8fdc\u7a0b\u670d\u52a1\u5668\u548c\u4e91\u670d\u52a1\u4e5f\u662f\u4e00\u79cd\u5b9e\u73b0\u540c\u65f6\u4f7f\u7528\u591a\u4e2aPython\u7248\u672c\u7684\u65b9\u6cd5\uff0c\u7279\u522b\u9002\u7528\u4e8e\u9700\u8981\u9ad8\u6027\u80fd\u8ba1\u7b97\u6216\u5206\u5e03\u5f0f\u8ba1\u7b97\u7684\u573a\u666f\u3002<\/p>\n<\/p>\n<p><h3>\u914d\u7f6e\u8fdc\u7a0b\u670d\u52a1\u5668<\/h3>\n<\/p>\n<ol>\n<li>\n<p><strong>\u9009\u62e9\u8fdc\u7a0b\u670d\u52a1\u5668\u63d0\u4f9b\u5546<\/strong>\uff1a<\/p>\n<\/p>\n<ul>\n<li>AWS\uff08Amazon Web Services\uff09<\/li>\n<li>Google Cloud Platform<\/li>\n<li>Microsoft Azure<\/li>\n<li>DigitalOcean<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>\u914d\u7f6e\u8fdc\u7a0b\u670d\u52a1\u5668<\/strong>\uff1a<\/p>\n<p>\u6839\u636e\u63d0\u4f9b\u5546\u7684\u6307\u5357\u914d\u7f6e\u8fdc\u7a0b\u670d\u52a1\u5668\uff0c\u5305\u62ec\u64cd\u4f5c\u7cfb\u7edf\u3001\u7f51\u7edc\u8bbe\u7f6e\u548c\u5b89\u5168\u7ec4\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u5b89\u88c5Python\u548c\u865a\u62df\u73af\u5883<\/strong>\uff1a<\/p>\n<p>\u5728\u8fdc\u7a0b\u670d\u52a1\u5668\u4e0a\u5b89\u88c5\u6240\u9700\u7684Python\u7248\u672c\u548c\u865a\u62df\u73af\u5883\u5de5\u5177\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">sudo apt-get install python3.8<\/p>\n<p>sudo apt-get install python3.9<\/p>\n<p>pip install virtualenv<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u8fde\u63a5\u8fdc\u7a0b\u670d\u52a1\u5668<\/strong>\uff1a<\/p>\n<p>\u4f7f\u7528SSH\u8fde\u63a5\u5230\u8fdc\u7a0b\u670d\u52a1\u5668\uff0c\u5e76\u5728\u8fdc\u7a0b\u670d\u52a1\u5668\u4e0a\u8fd0\u884cPython\u7a0b\u5e8f\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">ssh user@remote_server_ip<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<\/ol>\n<p><h3>\u4f7f\u7528\u4e91\u670d\u52a1<\/h3>\n<\/p>\n<ol>\n<li>\n<p><strong>\u9009\u62e9\u4e91\u670d\u52a1\u63d0\u4f9b\u5546<\/strong>\uff1a<\/p>\n<\/p>\n<ul>\n<li>AWS Lambda<\/li>\n<li>Google Cloud Functions<\/li>\n<li>Azure Functions<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>\u914d\u7f6e\u4e91\u51fd\u6570<\/strong>\uff1a<\/p>\n<p>\u6839\u636e\u63d0\u4f9b\u5546\u7684\u6307\u5357\u914d\u7f6e\u4e91\u51fd\u6570\uff0c\u5305\u62ec\u8fd0\u884c\u65f6\u73af\u5883\u3001\u89e6\u53d1\u5668\u548c\u4f9d\u8d56\u9879\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u90e8\u7f72Python\u4ee3\u7801<\/strong>\uff1a<\/p>\n<p>\u5c06Python\u4ee3\u7801\u90e8\u7f72\u5230\u4e91\u51fd\u6570\u4e2d\uff0c\u5e76\u5728\u4e91\u73af\u5883\u4e2d\u8fd0\u884c\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><h3>\u8fdc\u7a0bJupyter Notebook\u548cJupyterLab<\/h3>\n<\/p>\n<ol>\n<li>\n<p><strong>\u914d\u7f6e\u8fdc\u7a0bJupyter Notebook\u548cJupyterLab<\/strong>\uff1a<\/p>\n<p>\u5728\u8fdc\u7a0b\u670d\u52a1\u5668\u4e0a\u5b89\u88c5\u548c\u914d\u7f6eJupyter Notebook\u6216JupyterLab\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip install notebook<\/p>\n<p>pip install jupyterlab<\/p>\n<p>jupyter notebook --no-browser --port=8888<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u8bbe\u7f6eSSH\u96a7\u9053<\/strong>\uff1a<\/p>\n<p>\u5728\u672c\u5730\u673a\u5668\u4e0a\u8bbe\u7f6eSSH\u96a7\u9053\uff0c\u8bbf\u95ee\u8fdc\u7a0bJupyter Notebook\u6216JupyterLab\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">ssh -L 8888:localhost:8888 user@remote_server_ip<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u8bbf\u95ee\u8fdc\u7a0bJupyter Notebook\u548cJupyterLab<\/strong>\uff1a<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u5728\u540c\u4e00\u53f0\u673a\u5668\u4e0a\u5b89\u88c5\u591a\u4e2a\u7248\u672c\u7684Python\uff1f<\/strong><br \/>\u5728\u540c\u4e00\u53f0\u673a\u5668\u4e0a\u5b89\u88c5\u591a\u4e2a\u7248\u672c\u7684Python\u53ef\u4ee5\u901a\u8fc7\u4f7f\u7528\u5b98\u65b9\u7684\u5b89\u88c5\u7a0b\u5e8f\u6216\u8005\u4f7f\u7528\u5305\u7ba1\u7406\u5de5\u5177\u5982Anaconda\u548cpyenv\u6765\u5b9e\u73b0\u3002\u5b98\u65b9\u5b89\u88c5\u7a0b\u5e8f\u5141\u8bb8\u60a8\u5728\u5b89\u88c5\u65f6\u9009\u62e9\u4e0d\u540c\u7684\u5b89\u88c5\u8def\u5f84\uff0c\u800cAnaconda\u548cpyenv\u63d0\u4f9b\u4e86\u66f4\u65b9\u4fbf\u7684\u7248\u672c\u7ba1\u7406\u529f\u80fd\uff0c\u53ef\u4ee5\u8f7b\u677e\u5207\u6362\u4e0d\u540c\u7684Python\u7248\u672c\u3002\u786e\u4fdd\u5728\u5b89\u88c5\u8fc7\u7a0b\u4e2d\u8bbe\u7f6e\u597d\u73af\u5883\u53d8\u91cf\uff0c\u4ee5\u4fbf\u5728\u7ec8\u7aef\u4e2d\u6b63\u786e\u8c03\u7528\u76f8\u5e94\u7684Python\u7248\u672c\u3002<\/p>\n<p><strong>\u5982\u4f55\u5728\u9879\u76ee\u4e2d\u6307\u5b9a\u4f7f\u7528\u7279\u5b9a\u7248\u672c\u7684Python\uff1f<\/strong><br \/>\u5728\u9879\u76ee\u4e2d\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528\u865a\u62df\u73af\u5883\u6765\u6307\u5b9a\u4f7f\u7528\u7279\u5b9a\u7248\u672c\u7684Python\u3002\u53ef\u4ee5\u901a\u8fc7<code>venv<\/code>\u6216<code>virtualenv<\/code>\u521b\u5efa\u4e00\u4e2a\u865a\u62df\u73af\u5883\uff0c\u6307\u5b9a\u6240\u9700\u7684Python\u7248\u672c\u3002\u521b\u5efa\u865a\u62df\u73af\u5883\u65f6\uff0c\u63d0\u4f9bPython\u7684\u5b8c\u6574\u8def\u5f84\uff0c\u4f8b\u5982\uff1a<code>python3.8 -m venv myenv<\/code>\uff0c\u5728\u6fc0\u6d3b\u8be5\u73af\u5883\u540e\uff0c\u6240\u6709\u7684\u5305\u548c\u4f9d\u8d56\u90fd\u5c06\u9488\u5bf9\u6307\u5b9a\u7248\u672c\u7684Python\u8fdb\u884c\u7ba1\u7406\u3002<\/p>\n<p><strong>\u5982\u4f55\u7ba1\u7406\u548c\u5207\u6362\u4e0d\u540cPython\u7248\u672c\u7684\u4f9d\u8d56\uff1f<\/strong><br \/>\u5728\u7ba1\u7406\u591a\u4e2aPython\u7248\u672c\u7684\u4f9d\u8d56\u65f6\uff0c\u4f7f\u7528<code>requirements.txt<\/code>\u6587\u4ef6\u662f\u4e00\u4e2a\u597d\u65b9\u6cd5\u3002\u5bf9\u4e8e\u6bcf\u4e2a\u865a\u62df\u73af\u5883\uff0c\u53ef\u4ee5\u521b\u5efa\u4e00\u4e2a<code>requirements.txt<\/code>\uff0c\u5176\u4e2d\u5217\u51fa\u6240\u9700\u7684\u5305\u53ca\u5176\u7248\u672c\u3002\u4f7f\u7528<code>pip install -r requirements.txt<\/code>\u547d\u4ee4\u53ef\u4ee5\u65b9\u4fbf\u5730\u5b89\u88c5\u8fd9\u4e9b\u4f9d\u8d56\u3002\u5efa\u8bae\u5728\u6bcf\u6b21\u5207\u6362Python\u7248\u672c\u65f6\uff0c\u68c0\u67e5\u5e76\u66f4\u65b0\u76f8\u5e94\u7684\u4f9d\u8d56\uff0c\u4ee5\u786e\u4fdd\u517c\u5bb9\u6027\u548c\u7a33\u5b9a\u6027\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u4f7f\u7528\u865a\u62df\u73af\u5883\u3001\u5229\u7528\u4e0d\u540c\u7248\u672c\u7684Python\u89e3\u91ca\u5668\u3001\u4f7f\u7528\u5bb9\u5668\u5316\u6280\u672f\u5982Docker\uff0c\u53ef\u4ee5\u5b9e\u73b0\u540c\u65f6\u4f7f\u7528\u591a\u4e2aPython [&hellip;]","protected":false},"author":3,"featured_media":1152523,"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\/1152519"}],"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=1152519"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1152519\/revisions"}],"predecessor-version":[{"id":1152524,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1152519\/revisions\/1152524"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/1152523"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=1152519"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=1152519"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=1152519"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}