{"id":3174,"date":"2026-04-16T10:29:21","date_gmt":"2026-04-16T02:29:21","guid":{"rendered":"https:\/\/linuxjk.cn\/?p=3174"},"modified":"2026-04-16T10:29:24","modified_gmt":"2026-04-16T02:29:24","slug":"ubuntu-22-02-%e5%a4%9a%e7%89%88%e6%9c%acpython%e5%85%b1%e5%ad%98","status":"publish","type":"post","link":"https:\/\/linuxjk.cn\/?p=3174","title":{"rendered":"Ubuntu 22.02 \u591a\u7248\u672cpython\u5171\u5b58"},"content":{"rendered":"\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_82_2 counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">\u76ee\u5f55<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/linuxjk.cn\/?p=3174\/#%E5%AE%89%E8%A3%85_pyenv_%E4%BE%9D%E8%B5%96\" >\u5b89\u88c5 pyenv \u4f9d\u8d56<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/linuxjk.cn\/?p=3174\/#%E5%AE%89%E8%A3%85pyenv\" >\u5b89\u88c5pyenv<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/linuxjk.cn\/?p=3174\/#%E7%8E%AF%E5%A2%83%E5%8F%98%E9%87%8F%E9%85%8D%E7%BD%AE\" >\u73af\u5883\u53d8\u91cf\u914d\u7f6e<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/linuxjk.cn\/?p=3174\/#%E4%BD%BF%E7%94%A8_npmmirror_%E5%AE%89%E8%A3%85_Python_39\" >\u4f7f\u7528 npmmirror \u5b89\u88c5 Python 3.9<\/a><\/li><\/ul><\/nav><\/div>\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E5%AE%89%E8%A3%85_pyenv_%E4%BE%9D%E8%B5%96\"><\/span>\u5b89\u88c5 pyenv \u4f9d\u8d56<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo apt install -y make build-essential libssl-dev zlib1g-dev \\\n  libbz2-dev libreadline-dev libsqlite3-dev curl llvm \\\n  libncursesw5-dev xz-utils tk-dev libxml2-dev libxmlsec1-dev \\\n  libffi-dev liblzma-dev git<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E5%AE%89%E8%A3%85pyenv\"><\/span>\u5b89\u88c5pyenv<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>#\u4e0b\u8f7dpyenv\nwget https:\/\/mirrors.aliyun.com\/ubuntu\/pool\/universe\/p\/pyenv\/pyenv_2.6.8-1_all.deb\n# 1. \u540c\u6837\u4ece\u963f\u91cc\u4e91\u4e0b\u8f7d pyenv-runtime\u4f9d\u8d56\u5305\nwget https:\/\/mirrors.aliyun.com\/ubuntu\/pool\/universe\/p\/pyenv\/pyenv-runtime_2.6.8-1_all.deb\n# \u5b89\u88c5\nsudo dpkg -i pyenv-runtime_2.6.8-1_all.deb pyenv_2.6.8-1_all.deb\n# \u5982\u679c\u6709\u4f9d\u8d56\u7f3a\u5931\uff0c\u8865\u88c5\u4f9d\u8d56\nsudo apt install -f<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E7%8E%AF%E5%A2%83%E5%8F%98%E9%87%8F%E9%85%8D%E7%BD%AE\"><\/span>\u73af\u5883\u53d8\u91cf\u914d\u7f6e<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>apt \u7248\u5b89\u88c5\u540e pyenv \u547d\u4ee4\u5373\u53ef\u7528\uff0c\n\n# \u68c0\u67e5 pyenv \u662f\u5426\u53ef\u8c03\u7528\npyenv --version\n\n#\u8bbe\u7f6e\u8f6f\u8fde\u63a5\uff0cpython3.9\u547d\u4ee4\u6307\u5411\u5bb6\u76ee\u5f55pyenv\u7684python3.9\u4e8c\u8fdb\u5236\u6587\u4ef6\nsudo ln -s ~\/.pyenv\/versions\/3.9.18\/bin\/python3.9 \/usr\/local\/bin\/python3.9\nsudo ln -s ~\/.pyenv\/versions\/3.9.18\/bin\/pip3.9 \/usr\/local\/bin\/pip3.9<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E4%BD%BF%E7%94%A8_npmmirror_%E5%AE%89%E8%A3%85_Python_39\"><\/span>\u4f7f\u7528 npmmirror \u5b89\u88c5 Python 3.9<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code># \u5b89\u88c5aliyun\u6e90\u7684python \u6e90\u7801\u538b\u7f29\u5305\uff0c\u518d\u7ed9pyenv\u4f7f\u7528\nmkdir -p ~\/.pyenv\/cache\nwget -O ~\/.pyenv\/cache\/Python-3.9.18.tar.xz \\\n  https:&#47;&#47;mirrors.aliyun.com\/python-release\/source\/Python-3.9.18.tar.xz\npyenv install 3.9.18\n# \u9a8c\u8bc1\u5df2\u5b89\u88c5\u7248\u672c\npyenv versions<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u5b89\u88c5 pyenv \u4f9d\u8d56 \u5b89\u88c5pyenv \u73af\u5883\u53d8\u91cf\u914d\u7f6e \u4f7f\u7528 npmmirror \u5b89\u88c5 Python 3.9<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[1],"tags":[],"class_list":["post-3174","post","type-post","status-publish","format-standard","hentry","category-vxhs888p"],"_links":{"self":[{"href":"https:\/\/linuxjk.cn\/index.php?rest_route=\/wp\/v2\/posts\/3174","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/linuxjk.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/linuxjk.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/linuxjk.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/linuxjk.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3174"}],"version-history":[{"count":1,"href":"https:\/\/linuxjk.cn\/index.php?rest_route=\/wp\/v2\/posts\/3174\/revisions"}],"predecessor-version":[{"id":3175,"href":"https:\/\/linuxjk.cn\/index.php?rest_route=\/wp\/v2\/posts\/3174\/revisions\/3175"}],"wp:attachment":[{"href":"https:\/\/linuxjk.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3174"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/linuxjk.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3174"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/linuxjk.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3174"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}