{"id":70473,"date":"2023-11-23T21:01:33","date_gmt":"2023-11-23T13:01:33","guid":{"rendered":"https:\/\/www.hongkiat.com\/blog\/?p=70473"},"modified":"2023-11-21T22:21:30","modified_gmt":"2023-11-21T14:21:30","slug":"map-python-python3","status":"publish","type":"post","link":"https:\/\/www.hongkiat.com\/blog\/map-python-python3\/","title":{"rendered":"How to Map &#8216;python&#8217; to &#8216;python3&#8217; on Mac"},"content":{"rendered":"<p>In this tutorial, we\u2019ll explore how to configure your machine to use the <code>python<\/code> command instead of <code>python3<\/code>.<\/p>\n<p>When you install Python 3 or the latest version of Python on your Mac, it\u2019s typically executed using the <code>python3<\/code> command. However, if you prefer to use Python 3 while running it with just the <code>python<\/code> command, this guide is for you.<\/p>\n<figure><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/assets.hongkiat.com\/uploads\/map-python-python3\/hero.jpg\" alt=\"Python3 Mac Terminal\" width=\"1600\" height=\"900\"><\/figure>\n<p>Before we proceed with the tutorial, I assume that you already have Python installed on your Mac. If you haven\u2019t installed it yet, please refer to this guide on <a href=\"https:\/\/docs.python-guide.org\/starting\/install3\/osx\/\">how to install Python on your Mac<\/a>.<\/p>\n<p>Let\u2019s dive in.<\/p>\n<h2>Mapping \u2018python\u2019 to \u2018python3\u2019<\/h2>\n<p>To change the default <code>python3<\/code> command on your Mac to point to <code>python<\/code>, you can create an alias. This is done by modifying your shell\u2019s configuration file. Here\u2019s how to do it:<\/p>\n<h3>Step 1: Open Terminal<\/h3>\n<p>You can find it in the Applications folder under Utilities, or search for it using Spotlight.<\/p>\n<h3>Step 2: Determine Your Shell<\/h3>\n<p>macOS uses either <em>bash<\/em> or <em>zsh<\/em> as the default shell. You can determine which one you\u2019re using by running <code>echo $SHELL<\/code> in the terminal.<\/p>\n<h3>Step 3: Edit the Configuration File<\/h3>\n<ul>\n<li>If you\u2019re using <em>bash<\/em>, you\u2019ll edit <code>~\/.bash_profile<\/code>, <code>~\/.bashrc<\/code>, or <code>~\/.profile<\/code>.<\/li>\n<li>If you\u2019re using zsh, you\u2019ll edit <code>~\/.zshrc<\/code>.<\/li>\n<\/ul>\n<h3>Step 4: Add an Alias<\/h3>\n<p>Open the appropriate file in a text editor, such as Nano, by typing <code>nano ~\/.bash_profile<\/code> or <code>nano ~\/.zshrc<\/code> (depending on your shell).<\/p>\n<p>Add the following line to the file: <code>alias python='python3'<\/code>.<\/p>\n<p>Save and close the file (in Nano, this is done by pressing <span class=\"key\">Ctrl<\/span> + <span class=\"key\">X<\/span> , then <span class=\"key\">Y<\/span> to confirm, and <span class=\"key\">Enter<\/span> to exit).<\/p>\n<h3>Step 5: Apply the Changes<\/h3>\n<p>For the changes to take effect, you either need to restart your terminal or source the profile file by typing <code>source ~\/.bash_profile<\/code> or <code>source ~\/.zshrc<\/code>.<\/p>\n<p>After doing this, when you type python in your terminal, it should now use <code>python3<\/code>. Keep in mind that this change is specific to your user account on the Mac, and it won\u2019t affect system-level Python configurations.<\/p>\n<h2>Didn\u2019t Work? Check the Following:<\/h2>\n<p>If setting an alias didn\u2019t work, there might be a few reasons why. Let\u2019s try a different approach:<\/p>\n<h3>1. Check Your Shell Again<\/h3>\n<p>First, ensure that you edited the correct configuration file for your shell. Run <code>echo $SHELL<\/code> in the Terminal to confirm your shell. If it\u2019s <em>zsh<\/em>, the file is <code>~\/.zshrc<\/code>. For <em>bash<\/em>, it\u2019s one of <code>~\/.bash_profile<\/code>, <code>~\/.bashrc<\/code>, or <code>~\/.profile<\/code>.<\/p>\n<h3>2. Verify Alias Syntax<\/h3>\n<p>Make sure that the alias line in your configuration file is exactly as follows:<\/p>\n<pre>alias python='python3'<\/pre>\n<p>There should be no extra spaces or characters.<\/p>\n<h3>3. Recheck Configuration File<\/h3>\n<p>Double-check that you saved the changes to the configuration file.<\/p>\n<h3>4. Source the Configuration File<\/h3>\n<p>Run <code>source ~\/.zshrc<\/code> (for zsh) or <code>source ~\/.bash_profile<\/code> (for bash) to apply the changes immediately. If this step is missed, the alias won\u2019t work until the next time you log in.<\/p>\n<h3>5. Restart Terminal<\/h3>\n<p>After sourcing the configuration file, close and reopen the Terminal. Sometimes a fresh start is needed.<\/p>\n<h3>6. Check for Conflicts<\/h3>\n<p>If you have other configuration files (like <code>~\/.bashrc<\/code> or <code>~\/.profile<\/code>), they might conflict. Check those files for any existing python <code>aliases<\/code> or <code>PATH<\/code> modifications.<\/p>\n<h3>7. Check Your PATH<\/h3>\n<p>Ensure that the directory containing the <code>python3<\/code> executable is in your <code>PATH<\/code>. Run <code>echo $PATH<\/code> to see your current <code>PATH<\/code>.<\/p>\n<h3>8. Test the Alias Directly<\/h3>\n<p>Try setting the alias directly in the Terminal (not through the file) to see if it works:<\/p>\n<pre>alias python='python3'\r\npython --version<\/pre>\n<p>If this works, the issue is likely with how the configuration file is being sourced.<\/p>\n<h3>9. Use Absolute Path<\/h3>\n<p>If the alias still doesn\u2019t work, you can use the absolute path to the <code>python3<\/code> executable. Find it using which python3, and then set the alias with that path:<\/p>\n<pre>alias python='\/absolute\/path\/to\/python3'<\/pre>","protected":false},"excerpt":{"rendered":"<p>In this tutorial, we\u2019ll explore how to configure your machine to use the python command instead of python3. When you install Python 3 or the latest version of Python on your Mac, it\u2019s typically executed using the python3 command. However, if you prefer to use Python 3 while running it with just the python command,&hellip;<\/p>\n","protected":false},"author":9,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[3397],"tags":[3933,3729],"topic":[],"class_list":["entry-content","is-maxi"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v22.8 (Yoast SEO v27.6) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>How to Map &#039;python&#039; to &#039;python3&#039; on Mac - Hongkiat<\/title>\n<meta name=\"description\" content=\"In this tutorial, we&#039;ll explore how to configure your machine to use the python command instead of python3. When you install Python 3 or the latest\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.hongkiat.com\/blog\/map-python-python3\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Map &#039;python&#039; to &#039;python3&#039; on Mac\" \/>\n<meta property=\"og:description\" content=\"In this tutorial, we&#039;ll explore how to configure your machine to use the python command instead of python3. When you install Python 3 or the latest\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.hongkiat.com\/blog\/map-python-python3\/\" \/>\n<meta property=\"og:site_name\" content=\"Hongkiat\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/hongkiatcom\" \/>\n<meta property=\"article:published_time\" content=\"2023-11-23T13:01:33+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/assets.hongkiat.com\/uploads\/map-python-python3\/hero.jpg\" \/>\n<meta name=\"author\" content=\"Hongkiat.com\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@hongkiat\" \/>\n<meta name=\"twitter:site\" content=\"@hongkiat\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Hongkiat.com\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/map-python-python3\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/map-python-python3\\\/\"},\"author\":{\"name\":\"Hongkiat.com\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#\\\/schema\\\/person\\\/7cc686597d92f9086729e4bcc1577ba3\"},\"headline\":\"How to Map &#8216;python&#8217; to &#8216;python3&#8217; on Mac\",\"datePublished\":\"2023-11-23T13:01:33+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/map-python-python3\\\/\"},\"wordCount\":583,\"publisher\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/map-python-python3\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/assets.hongkiat.com\\\/uploads\\\/map-python-python3\\\/hero.jpg\",\"keywords\":[\"macOS\",\"python\"],\"articleSection\":[\"Desktop\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/map-python-python3\\\/\",\"url\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/map-python-python3\\\/\",\"name\":\"How to Map 'python' to 'python3' on Mac - Hongkiat\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/map-python-python3\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/map-python-python3\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/assets.hongkiat.com\\\/uploads\\\/map-python-python3\\\/hero.jpg\",\"datePublished\":\"2023-11-23T13:01:33+00:00\",\"description\":\"In this tutorial, we'll explore how to configure your machine to use the python command instead of python3. When you install Python 3 or the latest\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/map-python-python3\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/map-python-python3\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/map-python-python3\\\/#primaryimage\",\"url\":\"https:\\\/\\\/assets.hongkiat.com\\\/uploads\\\/map-python-python3\\\/hero.jpg\",\"contentUrl\":\"https:\\\/\\\/assets.hongkiat.com\\\/uploads\\\/map-python-python3\\\/hero.jpg\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/map-python-python3\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to Map &#8216;python&#8217; to &#8216;python3&#8217; on Mac\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/\",\"name\":\"Hongkiat\",\"description\":\"Tech and Design Tips\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#organization\",\"name\":\"Hongkiat.com\",\"url\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/wp-content\\\/uploads\\\/hkdc-logo-rect-yoast.jpg\",\"contentUrl\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/wp-content\\\/uploads\\\/hkdc-logo-rect-yoast.jpg\",\"width\":1200,\"height\":799,\"caption\":\"Hongkiat.com\"},\"image\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/hongkiatcom\",\"https:\\\/\\\/x.com\\\/hongkiat\",\"https:\\\/\\\/www.pinterest.com\\\/hongkiat\\\/\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#\\\/schema\\\/person\\\/7cc686597d92f9086729e4bcc1577ba3\",\"name\":\"Hongkiat.com\",\"description\":\"This post is published by an HKDC (hongkiat.com) staff. (I.e., intern, staff writer, or editor).\",\"sameAs\":[\"https:\\\/\\\/www.hongkiat.com\"],\"url\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/author\\\/com\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"How to Map 'python' to 'python3' on Mac - Hongkiat","description":"In this tutorial, we'll explore how to configure your machine to use the python command instead of python3. When you install Python 3 or the latest","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.hongkiat.com\/blog\/map-python-python3\/","og_locale":"en_US","og_type":"article","og_title":"How to Map 'python' to 'python3' on Mac","og_description":"In this tutorial, we'll explore how to configure your machine to use the python command instead of python3. When you install Python 3 or the latest","og_url":"https:\/\/www.hongkiat.com\/blog\/map-python-python3\/","og_site_name":"Hongkiat","article_publisher":"https:\/\/www.facebook.com\/hongkiatcom","article_published_time":"2023-11-23T13:01:33+00:00","og_image":[{"url":"https:\/\/assets.hongkiat.com\/uploads\/map-python-python3\/hero.jpg","type":"","width":"","height":""}],"author":"Hongkiat.com","twitter_card":"summary_large_image","twitter_creator":"@hongkiat","twitter_site":"@hongkiat","twitter_misc":{"Written by":"Hongkiat.com","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.hongkiat.com\/blog\/map-python-python3\/#article","isPartOf":{"@id":"https:\/\/www.hongkiat.com\/blog\/map-python-python3\/"},"author":{"name":"Hongkiat.com","@id":"https:\/\/www.hongkiat.com\/blog\/#\/schema\/person\/7cc686597d92f9086729e4bcc1577ba3"},"headline":"How to Map &#8216;python&#8217; to &#8216;python3&#8217; on Mac","datePublished":"2023-11-23T13:01:33+00:00","mainEntityOfPage":{"@id":"https:\/\/www.hongkiat.com\/blog\/map-python-python3\/"},"wordCount":583,"publisher":{"@id":"https:\/\/www.hongkiat.com\/blog\/#organization"},"image":{"@id":"https:\/\/www.hongkiat.com\/blog\/map-python-python3\/#primaryimage"},"thumbnailUrl":"https:\/\/assets.hongkiat.com\/uploads\/map-python-python3\/hero.jpg","keywords":["macOS","python"],"articleSection":["Desktop"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/www.hongkiat.com\/blog\/map-python-python3\/","url":"https:\/\/www.hongkiat.com\/blog\/map-python-python3\/","name":"How to Map 'python' to 'python3' on Mac - Hongkiat","isPartOf":{"@id":"https:\/\/www.hongkiat.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.hongkiat.com\/blog\/map-python-python3\/#primaryimage"},"image":{"@id":"https:\/\/www.hongkiat.com\/blog\/map-python-python3\/#primaryimage"},"thumbnailUrl":"https:\/\/assets.hongkiat.com\/uploads\/map-python-python3\/hero.jpg","datePublished":"2023-11-23T13:01:33+00:00","description":"In this tutorial, we'll explore how to configure your machine to use the python command instead of python3. When you install Python 3 or the latest","breadcrumb":{"@id":"https:\/\/www.hongkiat.com\/blog\/map-python-python3\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.hongkiat.com\/blog\/map-python-python3\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.hongkiat.com\/blog\/map-python-python3\/#primaryimage","url":"https:\/\/assets.hongkiat.com\/uploads\/map-python-python3\/hero.jpg","contentUrl":"https:\/\/assets.hongkiat.com\/uploads\/map-python-python3\/hero.jpg"},{"@type":"BreadcrumbList","@id":"https:\/\/www.hongkiat.com\/blog\/map-python-python3\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.hongkiat.com\/blog\/"},{"@type":"ListItem","position":2,"name":"How to Map &#8216;python&#8217; to &#8216;python3&#8217; on Mac"}]},{"@type":"WebSite","@id":"https:\/\/www.hongkiat.com\/blog\/#website","url":"https:\/\/www.hongkiat.com\/blog\/","name":"Hongkiat","description":"Tech and Design Tips","publisher":{"@id":"https:\/\/www.hongkiat.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.hongkiat.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.hongkiat.com\/blog\/#organization","name":"Hongkiat.com","url":"https:\/\/www.hongkiat.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.hongkiat.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/www.hongkiat.com\/blog\/wp-content\/uploads\/hkdc-logo-rect-yoast.jpg","contentUrl":"https:\/\/www.hongkiat.com\/blog\/wp-content\/uploads\/hkdc-logo-rect-yoast.jpg","width":1200,"height":799,"caption":"Hongkiat.com"},"image":{"@id":"https:\/\/www.hongkiat.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/hongkiatcom","https:\/\/x.com\/hongkiat","https:\/\/www.pinterest.com\/hongkiat\/"]},{"@type":"Person","@id":"https:\/\/www.hongkiat.com\/blog\/#\/schema\/person\/7cc686597d92f9086729e4bcc1577ba3","name":"Hongkiat.com","description":"This post is published by an HKDC (hongkiat.com) staff. (I.e., intern, staff writer, or editor).","sameAs":["https:\/\/www.hongkiat.com"],"url":"https:\/\/www.hongkiat.com\/blog\/author\/com\/"}]}},"jetpack_featured_media_url":"https:\/\/","jetpack_shortlink":"https:\/\/wp.me\/p4uxU-ikF","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/posts\/70473","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/users\/9"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/comments?post=70473"}],"version-history":[{"count":2,"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/posts\/70473\/revisions"}],"predecessor-version":[{"id":70475,"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/posts\/70473\/revisions\/70475"}],"wp:attachment":[{"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/media?parent=70473"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/categories?post=70473"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/tags?post=70473"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/topic?post=70473"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}