{"id":27,"date":"2022-08-18T23:29:06","date_gmt":"2022-08-18T23:29:06","guid":{"rendered":"https:\/\/alexaddison.com\/?p=27"},"modified":"2022-12-31T01:05:00","modified_gmt":"2022-12-31T01:05:00","slug":"how-to-cisc-python-packages-on-apple-risc-silicon","status":"publish","type":"post","link":"https:\/\/alexaddison.com\/?p=27","title":{"rendered":"How to: CISC Python packages on Apple RISC Silicon"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Unfortunately, several popular data science Python packages like Pandas and Numpy don&#8217;t currently compile on the M1 or M2 chip. This post will outline an easy way to set-it-and-forget-it using Rosetta 2, which emulates Intel CISC instructions on Apple Silicon. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><em>But what&#8217;s the advantage of doing it this way? What are the disadvantages?<\/em><br>Typically, you do not want to create more Python chaos than already exists, as this ecosystem can be a huge PITA to deal with.<br>\u2022 This method works because the code is picked up from your system &amp; sent off to the Intel x86_64 compilation queue instead of the arm64 compilation queue.<br>\u2022 The disadvantage is that you&#8217;re going to end up maintaining two environments. For example, if you try to run something that&#8217;s unavailable, e.g. you installed a package with arm64 and try to run it in Intel x86_64 mode, it will fail along the lines of:<br><code>incompatible architecture (have 'arm64', need 'x86_64'))<\/code><br>\u2022&nbsp;The good news is that as long as you stick with pipenv, homebrew, or macports then walking back the system installation is usually easy if imperfect.<br><br><em>How to:<\/em><br>\u2022&nbsp;Download an alternative terminal app like iTerm2. This will set up all operations contained by the app to run in Intel x86 emulation mode, and the Python packages will compile using pipenv. <br><br>(Optional) Set up your terminal to notify you each time you open a new window by adding &#8220;echo $(uname -m)&#8221; to your .zshrc file. Kudos to indiespark for the tip about environment notification &#8211; see footnote for more info.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>echo $(uname -m)<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/alexaddison.com\/wp-content\/uploads\/2022\/07\/Screen-Shot-2022-07-23-at-4.53.25-PM-1024x57.png\" alt=\"\" class=\"wp-image-32\" width=\"1026\" height=\"57\" srcset=\"https:\/\/alexaddison.com\/wp-content\/uploads\/2022\/07\/Screen-Shot-2022-07-23-at-4.53.25-PM-1024x57.png 1024w, https:\/\/alexaddison.com\/wp-content\/uploads\/2022\/07\/Screen-Shot-2022-07-23-at-4.53.25-PM-300x17.png 300w, https:\/\/alexaddison.com\/wp-content\/uploads\/2022\/07\/Screen-Shot-2022-07-23-at-4.53.25-PM-768x43.png 768w, https:\/\/alexaddison.com\/wp-content\/uploads\/2022\/07\/Screen-Shot-2022-07-23-at-4.53.25-PM-1536x86.png 1536w, https:\/\/alexaddison.com\/wp-content\/uploads\/2022\/07\/Screen-Shot-2022-07-23-at-4.53.25-PM-2048x114.png 2048w, https:\/\/alexaddison.com\/wp-content\/uploads\/2022\/07\/Screen-Shot-2022-07-23-at-4.53.25-PM-1568x87.png 1568w\" sizes=\"auto, (max-width: 1026px) 100vw, 1026px\" \/><figcaption class=\"wp-element-caption\">Left: arm64 &#8211; Right: x86_64 emulator<\/figcaption><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">(Optional) Back in the Finder, I customized the Icon by pasting &#8220;x86&#8221; over the terminal icon in Photoshop, and on top of that, I&#8217;ve effectively created a second python environment. <\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"427\" height=\"211\" src=\"https:\/\/alexaddison.com\/wp-content\/uploads\/2022\/07\/Screen-Shot-2022-07-24-at-7.04.54-PM.png\" alt=\"\" class=\"wp-image-42\" srcset=\"https:\/\/alexaddison.com\/wp-content\/uploads\/2022\/07\/Screen-Shot-2022-07-24-at-7.04.54-PM.png 427w, https:\/\/alexaddison.com\/wp-content\/uploads\/2022\/07\/Screen-Shot-2022-07-24-at-7.04.54-PM-300x148.png 300w\" sizes=\"auto, (max-width: 427px) 100vw, 427px\" \/><figcaption class=\"wp-element-caption\">Easily visible icon for intel environment, or you can use another app like iTerm<\/figcaption><\/figure>\n<\/div>\n\n\n<p class=\"wp-block-paragraph\">Duplicating Terminal seems like a non-starter, and I would avoid doing that. Using a totally different app is safer for this use case.<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Here&#8217;s a good read about <a rel=\"noreferrer noopener\" href=\"https:\/\/indiespark.top\/software\/detecting-apple-silicon-shell-script\/\" target=\"_blank\">arm64 and intel modes<\/a> that can outline the difference in more detail.<\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>Running Intel-era python packages on Apple Silicon<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[14],"tags":[13,17,4,12],"class_list":["post-27","post","type-post","status-publish","format-standard","hentry","category-nerds","tag-cisc","tag-mx-platform","tag-python","tag-risc"],"_links":{"self":[{"href":"https:\/\/alexaddison.com\/index.php?rest_route=\/wp\/v2\/posts\/27","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/alexaddison.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/alexaddison.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/alexaddison.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/alexaddison.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=27"}],"version-history":[{"count":21,"href":"https:\/\/alexaddison.com\/index.php?rest_route=\/wp\/v2\/posts\/27\/revisions"}],"predecessor-version":[{"id":122,"href":"https:\/\/alexaddison.com\/index.php?rest_route=\/wp\/v2\/posts\/27\/revisions\/122"}],"wp:attachment":[{"href":"https:\/\/alexaddison.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=27"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/alexaddison.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=27"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/alexaddison.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=27"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}