{"id":982438,"date":"2024-12-27T07:10:54","date_gmt":"2024-12-26T23:10:54","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/982438.html"},"modified":"2024-12-27T07:10:56","modified_gmt":"2024-12-26T23:10:56","slug":"fedora-23%e5%a6%82%e4%bd%95%e6%89%93%e5%bc%80python","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/982438.html","title":{"rendered":"fedora 23\u5982\u4f55\u6253\u5f00python"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/24210923\/396cf5b8-6033-4757-9dce-59e35cd0f14d.webp\" alt=\"fedora 23\u5982\u4f55\u6253\u5f00python\" \/><\/p>\n<p><p> <strong>\u5728Fedora 23\u4e2d\u6253\u5f00Python\uff0c\u53ef\u4ee5\u901a\u8fc7\u7ec8\u7aef\u8f93\u5165\u547d\u4ee4\u3001\u4f7f\u7528Python\u4ea4\u4e92\u5f0f\u89e3\u91ca\u5668\u3001\u4ee5\u53ca\u901a\u8fc7\u96c6\u6210\u5f00\u53d1\u73af\u5883\uff08IDE\uff09\u7b49\u65b9\u5f0f\u5b9e\u73b0\u3002<\/strong> \u5176\u4e2d\uff0c\u6700\u7b80\u5355\u7684\u65b9\u6cd5\u662f\u4f7f\u7528\u7ec8\u7aef\u547d\u4ee4\u6253\u5f00Python\u89e3\u91ca\u5668\u3002\u6253\u5f00\u7ec8\u7aef\u540e\uff0c\u8f93\u5165<code>python<\/code>\u6216<code>python3<\/code>\u547d\u4ee4\u5373\u53ef\u542f\u52a8Python\u89e3\u91ca\u5668\u3002\u5728\u8fd9\u91cc\uff0c\u6211\u4eec\u5c06\u8be6\u7ec6\u63a2\u8ba8\u5982\u4f55\u5728Fedora 23\u4e2d\u901a\u8fc7\u4e0d\u540c\u65b9\u5f0f\u6253\u5f00\u548c\u4f7f\u7528Python\u3002<\/p>\n<\/p>\n<p><p>\u4e00\u3001\u7ec8\u7aef\u547d\u4ee4\u6253\u5f00Python<\/p>\n<\/p>\n<p><p>\u5728Fedora 23\u4e2d\uff0c\u6253\u5f00\u7ec8\u7aef\u662f\u4f7f\u7528Python\u7684\u6700\u76f4\u63a5\u65b9\u6cd5\u4e4b\u4e00\u3002\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0cFedora 23\u9884\u88c5\u4e86Python 2\u548cPython 3\u3002\u8981\u6253\u5f00Python 2\u7684\u4ea4\u4e92\u5f0f\u89e3\u91ca\u5668\uff0c\u53ef\u4ee5\u5728\u7ec8\u7aef\u4e2d\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">python<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8981\u6253\u5f00Python 3\u7684\u4ea4\u4e92\u5f0f\u89e3\u91ca\u5668\uff0c\u5219\u8f93\u5165\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">python3<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u5c06\u542f\u52a8Python\u4ea4\u4e92\u5f0f\u73af\u5883\uff0c\u60a8\u53ef\u4ee5\u5728\u5176\u4e2d\u8f93\u5165Python\u4ee3\u7801\u5e76\u7acb\u5373\u67e5\u770b\u8f93\u51fa\u3002\u8fd9\u79cd\u65b9\u6cd5\u7279\u522b\u9002\u5408\u5feb\u901f\u6d4b\u8bd5\u5c0f\u6bb5\u4ee3\u7801\u6216\u8fdb\u884c\u7b80\u5355\u7684\u8ba1\u7b97\u3002<\/p>\n<\/p>\n<p><p>\u4e8c\u3001\u4f7f\u7528Python\u811a\u672c<\/p>\n<\/p>\n<p><p>\u9664\u4e86\u901a\u8fc7\u4ea4\u4e92\u5f0f\u89e3\u91ca\u5668\u76f4\u63a5\u8f93\u5165\u4ee3\u7801\u5916\uff0c\u60a8\u8fd8\u53ef\u4ee5\u5728\u6587\u672c\u7f16\u8f91\u5668\u4e2d\u7f16\u5199Python\u811a\u672c\uff0c\u7136\u540e\u901a\u8fc7\u7ec8\u7aef\u8fd0\u884c\u5b83\u4eec\u3002\u4ee5\u4e0b\u662f\u4f7f\u7528Python\u811a\u672c\u7684\u6b65\u9aa4\uff1a<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u7f16\u5199\u811a\u672c<\/strong>\uff1a\u4f7f\u7528\u6587\u672c\u7f16\u8f91\u5668\uff08\u5982Gedit\u3001Vim\u6216Nano\uff09\u521b\u5efa\u4e00\u4e2a\u65b0\u7684Python\u6587\u4ef6\u3002\u4f8b\u5982\uff0c\u521b\u5efa\u4e00\u4e2a\u540d\u4e3a<code>example.py<\/code>\u7684\u6587\u4ef6\uff0c\u5e76\u8f93\u5165\u4ee5\u4e0b\u4ee3\u7801\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">print(&quot;Hello, Fedora 23!&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u4fdd\u5b58\u5e76\u5173\u95ed\u6587\u4ef6<\/strong>\uff1a\u4fdd\u5b58\u6587\u4ef6\u5e76\u5173\u95ed\u6587\u672c\u7f16\u8f91\u5668\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u8fd0\u884c\u811a\u672c<\/strong>\uff1a\u5728\u7ec8\u7aef\u4e2d\u5bfc\u822a\u5230\u6587\u4ef6\u6240\u5728\u7684\u76ee\u5f55\uff0c\u7136\u540e\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u8fd0\u884c\u811a\u672c\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">python example.py<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p> \u6216\u8005\uff0c\u5982\u679c\u60a8\u4f7f\u7528Python 3\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">python3 example.py<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u4e09\u3001\u4f7f\u7528\u96c6\u6210\u5f00\u53d1\u73af\u5883\uff08IDE\uff09<\/p>\n<\/p>\n<p><p>\u5bf9\u4e8e\u66f4\u590d\u6742\u7684\u9879\u76ee\uff0c\u4f7f\u7528\u96c6\u6210\u5f00\u53d1\u73af\u5883\uff08IDE\uff09\u53ef\u4ee5\u63d0\u9ad8\u6548\u7387\u548c\u5f00\u53d1\u4f53\u9a8c\u3002\u4ee5\u4e0b\u662f\u4e00\u4e9b\u6d41\u884c\u7684Python IDE\u53ca\u5176\u5728Fedora 23\u4e2d\u7684\u5b89\u88c5\u548c\u4f7f\u7528\u65b9\u6cd5\uff1a<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>PyCharm<\/strong>\uff1aPyCharm\u662f\u4e00\u4e2a\u529f\u80fd\u5f3a\u5927\u7684Python IDE\u3002\u53ef\u4ee5\u901a\u8fc7Snap\u6216Flatpak\u5b89\u88c5\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">sudo snap install pycharm-community --classic<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5b89\u88c5\u540e\uff0c\u60a8\u53ef\u4ee5\u901a\u8fc7\u5e94\u7528\u7a0b\u5e8f\u83dc\u5355\u542f\u52a8PyCharm\uff0c\u5e76\u521b\u5efa\u6216\u6253\u5f00Python\u9879\u76ee\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>Visual Studio Code<\/strong>\uff1aVSCode\u662f\u4e00\u6b3e\u6d41\u884c\u7684\u8f7b\u91cf\u7ea7\u4ee3\u7801\u7f16\u8f91\u5668\uff0c\u652f\u6301Python\u5f00\u53d1\u3002\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4\u5b89\u88c5\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">sudo dnf install code<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5b89\u88c5Python\u6269\u5c55\u540e\uff0c\u60a8\u53ef\u4ee5\u5728VSCode\u4e2d\u7f16\u5199\u3001\u8c03\u8bd5\u548c\u8fd0\u884cPython\u4ee3\u7801\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u56db\u3001\u914d\u7f6e\u548c\u7ba1\u7406Python\u73af\u5883<\/p>\n<\/p>\n<p><p>\u5728Fedora 23\u4e2d\uff0c\u7ba1\u7406Python\u73af\u5883\u662f\u786e\u4fdd\u9879\u76ee\u4f9d\u8d56\u6027\u548c\u517c\u5bb9\u6027\u7684\u91cd\u8981\u65b9\u9762\u3002\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u5de5\u5177\uff1a<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>Virtualenv<\/strong>\uff1a\u7528\u4e8e\u521b\u5efa\u72ec\u7acb\u7684Python\u73af\u5883\u3002\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4\u5b89\u88c5\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">sudo dnf install python-virtualenv<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u521b\u5efa\u865a\u62df\u73af\u5883\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">virtualenv myenv<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u6fc0\u6d3b\u865a\u62df\u73af\u5883\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">source myenv\/bin\/activate<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>Pipenv<\/strong>\uff1a\u4e00\u4e2aPython\u5305\u7ba1\u7406\u5de5\u5177\uff0c\u96c6\u6210\u4e86\u5305\u7ba1\u7406\u548c\u73af\u5883\u7ba1\u7406\u529f\u80fd\u3002\u5b89\u88c5\u547d\u4ee4\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">sudo dnf install pipenv<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u4f7f\u7528Pipenv\u521b\u5efa\u548c\u7ba1\u7406\u9879\u76ee\u73af\u5883\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pipenv install<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u4e94\u3001\u5b89\u88c5\u548c\u7ba1\u7406Python\u5305<\/p>\n<\/p>\n<p><p>\u5728Fedora 23\u4e0a\uff0c\u4f7f\u7528<code>pip<\/code>\u662f\u5b89\u88c5\u548c\u7ba1\u7406Python\u5305\u7684\u6807\u51c6\u65b9\u6cd5\u3002\u4ee5\u4e0b\u662f\u4e00\u4e9b\u5e38\u7528\u7684<code>pip<\/code>\u547d\u4ee4\uff1a<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u5b89\u88c5\u5305<\/strong>\uff1a\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u5b89\u88c5Python\u5305\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip install package-name<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u6216\u8005\uff0c\u5bf9\u4e8ePython 3\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip3 install package-name<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u5217\u51fa\u5df2\u5b89\u88c5\u5305<\/strong>\uff1a\u67e5\u770b\u5f53\u524d\u73af\u5883\u4e2d\u5df2\u5b89\u88c5\u7684\u5305\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip list<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u5347\u7ea7\u5305<\/strong>\uff1a\u5c06\u5df2\u5b89\u88c5\u7684\u5305\u5347\u7ea7\u5230\u6700\u65b0\u7248\u672c\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip install --upgrade package-name<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u5378\u8f7d\u5305<\/strong>\uff1a\u79fb\u9664\u4e0d\u518d\u9700\u8981\u7684\u5305\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip uninstall package-name<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u516d\u3001\u89e3\u51b3\u5e38\u89c1\u95ee\u9898<\/p>\n<\/p>\n<p><p>\u5728\u4f7f\u7528Python\u65f6\uff0c\u60a8\u53ef\u80fd\u4f1a\u9047\u5230\u4e00\u4e9b\u5e38\u89c1\u95ee\u9898\u3002\u4ee5\u4e0b\u662f\u4e00\u4e9b\u89e3\u51b3\u65b9\u6848\uff1a<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>Python\u7248\u672c\u95ee\u9898<\/strong>\uff1a\u786e\u4fdd\u4f7f\u7528\u6b63\u786e\u7684Python\u7248\u672c\u3002\u6709\u65f6\u7cfb\u7edf\u9ed8\u8ba4Python\u7248\u672c\u53ef\u80fd\u4e0d\u662f\u60a8\u60f3\u8981\u7684\u7248\u672c\u3002\u5728\u547d\u4ee4\u4e2d\u660e\u786e\u6307\u5b9a<code>python3<\/code>\u4ee5\u4f7f\u7528Python 3\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u4f9d\u8d56\u51b2\u7a81<\/strong>\uff1a\u4f7f\u7528\u865a\u62df\u73af\u5883\u53ef\u4ee5\u907f\u514d\u4f9d\u8d56\u51b2\u7a81\u3002\u786e\u4fdd\u6bcf\u4e2a\u9879\u76ee\u90fd\u6709\u81ea\u5df1\u7684\u865a\u62df\u73af\u5883\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u5305\u5b89\u88c5\u5931\u8d25<\/strong>\uff1a\u5982\u679c\u67d0\u4e2a\u5305\u5b89\u88c5\u5931\u8d25\uff0c\u68c0\u67e5\u7f51\u7edc\u8fde\u63a5\u548cPyPI\u6e90\u914d\u7f6e\u3002\u53ef\u4ee5\u5c1d\u8bd5\u4f7f\u7528\u955c\u50cf\u6e90\u8fdb\u884c\u5b89\u88c5\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u6743\u9650\u95ee\u9898<\/strong>\uff1a\u6709\u65f6\u5b89\u88c5\u5168\u5c40\u5305\u53ef\u80fd\u9700\u8981\u7ba1\u7406\u5458\u6743\u9650\u3002\u53ef\u4ee5\u4f7f\u7528<code>sudo<\/code>\u547d\u4ee4\u6216\u5728\u865a\u62df\u73af\u5883\u4e2d\u5b89\u88c5\u5305\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u901a\u8fc7\u4ee5\u4e0a\u65b9\u6cd5\u548c\u6280\u5de7\uff0c\u60a8\u53ef\u4ee5\u5728Fedora 23\u4e2d\u987a\u5229\u6253\u5f00\u548c\u4f7f\u7528Python\u8fdb\u884c\u5f00\u53d1\u3002\u65e0\u8bba\u662f\u7b80\u5355\u7684\u811a\u672c\u7f16\u5199\u8fd8\u662f\u590d\u6742\u7684\u9879\u76ee\u5f00\u53d1\uff0c\u5408\u7406\u9009\u62e9\u5de5\u5177\u548c\u65b9\u6cd5\u5c06\u5e2e\u52a9\u60a8\u63d0\u9ad8\u5de5\u4f5c\u6548\u7387\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u5728Fedora 23\u4e0a\u68c0\u67e5\u662f\u5426\u5df2\u5b89\u88c5Python\uff1f<\/strong><br \/>\u5728Fedora 23\u4e0a\uff0c\u53ef\u4ee5\u901a\u8fc7\u6253\u5f00\u7ec8\u7aef\u5e76\u8f93\u5165\u547d\u4ee4<code>python --version<\/code>\u6216<code>python3 --version<\/code>\u6765\u68c0\u67e5Python\u662f\u5426\u5df2\u7ecf\u5b89\u88c5\u3002\u5982\u679c\u7cfb\u7edf\u8fd4\u56de\u7248\u672c\u53f7\uff0c\u8bf4\u660ePython\u5df2\u6210\u529f\u5b89\u88c5\u3002\u82e5\u672a\u5b89\u88c5\uff0c\u53ef\u4ee5\u901a\u8fc7\u5305\u7ba1\u7406\u5668\u8fdb\u884c\u5b89\u88c5\u3002<\/p>\n<p><strong>\u5728Fedora 23\u4e0a\u5982\u4f55\u5b89\u88c5\u6700\u65b0\u7248\u672c\u7684Python\uff1f<\/strong><br \/>\u53ef\u4ee5\u4f7f\u7528DNF\u5305\u7ba1\u7406\u5de5\u5177\u6765\u5b89\u88c5\u6700\u65b0\u7248\u672c\u7684Python\u3002\u5728\u7ec8\u7aef\u4e2d\u8f93\u5165\u547d\u4ee4<code>sudo dnf install python3<\/code>\uff0c\u7cfb\u7edf\u4f1a\u81ea\u52a8\u4e0b\u8f7d\u5e76\u5b89\u88c5Python3\u3002\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u60a8\u53ef\u4ee5\u901a\u8fc7\u547d\u4ee4<code>python3<\/code>\u6765\u8fd0\u884cPython\u3002<\/p>\n<p><strong>\u5982\u4f55\u5728Fedora 23\u4e0a\u8fd0\u884cPython\u811a\u672c\uff1f<\/strong><br \/>\u5728Fedora 23\u4e0a\u8fd0\u884cPython\u811a\u672c\u975e\u5e38\u7b80\u5355\u3002\u9996\u5148\uff0c\u786e\u4fdd\u60a8\u7684\u811a\u672c\u4ee5<code>.py<\/code>\u4e3a\u6269\u5c55\u540d\u3002\u6253\u5f00\u7ec8\u7aef\uff0c\u5bfc\u822a\u5230\u5b58\u653e\u811a\u672c\u7684\u76ee\u5f55\uff0c\u4f7f\u7528\u547d\u4ee4<code>python3 your_script.py<\/code>\u6765\u8fd0\u884c\u811a\u672c\u3002\u786e\u4fdd\u5728\u8fd0\u884c\u524d\u5df2\u6b63\u786e\u5b89\u88c5\u4e86Python\u53ca\u5176\u4f9d\u8d56\u5e93\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u5728Fedora 23\u4e2d\u6253\u5f00Python\uff0c\u53ef\u4ee5\u901a\u8fc7\u7ec8\u7aef\u8f93\u5165\u547d\u4ee4\u3001\u4f7f\u7528Python\u4ea4\u4e92\u5f0f\u89e3\u91ca\u5668\u3001\u4ee5\u53ca\u901a\u8fc7\u96c6\u6210\u5f00\u53d1\u73af [&hellip;]","protected":false},"author":3,"featured_media":982446,"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\/982438"}],"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=982438"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/982438\/revisions"}],"predecessor-version":[{"id":982449,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/982438\/revisions\/982449"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/982446"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=982438"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=982438"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=982438"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}