{"id":492,"date":"2018-01-30T22:08:49","date_gmt":"2018-01-30T14:08:49","guid":{"rendered":"https:\/\/www.techcoil.com\/blog\/?p=492"},"modified":"2018-07-11T12:56:10","modified_gmt":"2018-07-11T04:56:10","slug":"how-to-setup-raspbian-stretch-lite-on-raspberry-pi-3-to-run-python-3-applications","status":"publish","type":"post","link":"https:\/\/www.techcoil.com\/blog\/how-to-setup-raspbian-stretch-lite-on-raspberry-pi-3-to-run-python-3-applications\/","title":{"rendered":"How to setup Raspbian Stretch Lite on Raspberry Pi 3 to run Python 3 applications"},"content":{"rendered":"<p><a href=\"https:\/\/www.raspbian.org\/\" rel=\"noopener\" target=\"_blank\">Raspbian<\/a> Stretch Lite operating system is the <a href=\"https:\/\/www.raspberrypi.org\/\" rel=\"noopener\" target=\"_blank\">Raspberry Pi<\/a> Foundation's official supported operating system for running headless software. It is a good operating system for different Raspberry Pi 3 use cases. Some examples include:<\/p>\n<ul>\n<li><a href=\"https:\/\/www.techcoil.com\/blog\/how-i-setup-jenkins-on-my-raspberry-pi-3-with-raspbian-stretch-lite\/\">Jenkins for automating repetitive tasks.<\/a><\/li>\n<li><a href=\"https:\/\/www.techcoil.com\/blog\/setting-up-wordpress-on-raspberry-pi-3-with-raspbian-stretch-lite-nginx-mariadb-and-php-7-as-the-lemp-stack\/\" rel=\"noopener\" target=\"_blank\">WordPress site for personal blog<\/a><\/li>\n<\/ul>\n<p>If you are planning to use Raspberry Pi 3 GPIO to interface with the real world, it is recommended that you setup Raspbian Stretch Lite to run Python 3 applications. <\/p>\n<p>This post provides the steps to setup Raspbian Stretch Lite on Raspberry Pi 3 for running Python 3 applications.<\/p>\n<h2>Recommended hardware list<\/h2>\n<ul>\n<li><a href=\"https:\/\/www.amazon.com\/CanaKit-Raspberry-Micro-Supply-Listed\/dp\/B01C6FFNY4\/ref=as_li_ss_tl?s=pc&ie=UTF8&qid=1517212574&sr=1-4&keywords=raspberry+pi+3&linkCode=ll1&tag=clivsperswebs-20&linkId=76113a630916ac804456aa1f5dd76c85\" rel=\"noopener\" target=\"_blank\">CanaKit Raspberry Pi 3 with 2.5A Micro USB Power Supply<\/a> or <a href=\"https:\/\/www.amazon.com\/CanaKit-Raspberry-Power-Supply-Listed\/dp\/B07BC6WH7V\/\/ref=as_li_ss_tl?ie=UTF8&linkCode=ll1&tag=clivsperswebs-20&linkId=facc24accf03fbe5cd45b1893a1e9ab1\" rel=\"noopener\" target=\"_blank\">CanaKit Raspberry Pi 3 B+ (B Plus) with 2.5A Power Supply (UL Listed)<\/a><\/li>\n<li><a href=\"https:\/\/www.amazon.com\/dp\/B01F1PSFY6\/ref=as_li_ss_tl?ie=UTF8&linkCode=ll1&tag=clivsperswebs-20&linkId=d68c56d79a1d84f89f596fa715743a9e\" rel=\"noopener\" target=\"_blank\">Raspberry Pi 2\/3 official case Black\/Grey<\/a> or <a href=\"https:\/\/www.amazon.com\/dp\/B01CCPKCSK\/ref=as_li_ss_tl?ie=UTF8&linkCode=ll1&tag=clivsperswebs-20&linkId=1e69ae5649504fb86c6597e0774eb3d8\" rel=\"noopener\" target=\"_blank\">Raspberry Pi 2\/3 official case Red\/White<\/a><\/li>\n<li><a href=\"https:\/\/www.amazon.com\/Sandisk-Ultra-Micro-UHS-I-Adapter\/dp\/B073JWXGNT\/ref=as_li_ss_tl?ie=UTF8&linkCode=ll1&tag=clivsperswebs-20&linkId=20db403fc5e8bbc15e46ec21868a1488\" rel=\"noopener\" target=\"_blank\"> Sandisk Ultra 32GB Micro SDHC UHS-I Card with Adapter<\/a><\/li>\n<li><a href=\"https:\/\/www.amazon.com\/gp\/product\/B00N2VISLW\/ref=as_li_tl?ie=UTF8&tag=clivsperswebs-20&camp=1789&creative=9325&linkCode=as2&creativeASIN=B00N2VISLW&linkId=132403a064ff21634835c1deee4bc983\" target=\"_blank\">AmazonBasics RJ45 Cat-6 Ethernet Patch Cable - 3 Feet (0.9 Meters)<\/a><\/li>\n<\/ul>\n<h2>Setting up Raspbian Stretch Lite with SSH server enabled on your microSD card<\/h2>\n<p>Once you had gathered all the necessary hardware, proceed to <a href=\"https:\/\/www.techcoil.com\/blog\/how-to-setup-raspbian-stretch-lite-with-ssh-server-enabled-on-your-microsd-card\/\" rel=\"noopener\" target=\"_blank\">setup Raspbian Stretch Lite with SSH server enabled on your microSD card<\/a>. Doing so will allow you to SSH into your Raspbian Stretch Lite to perform further configurations in this post. <\/p>\n<h2>Assembling the hardware for the Raspberry Pi 3<\/h2>\n<p>Once the ssh file is created in the boot partition of the microSD card, remove the microSD card from your SD card reader and insert it to the microSD card slot on the Raspberry Pi 3 board. After that, proceed to <a href=\"\/blog\/how-to-assemble-the-raspberry-pi-3-board-with-the-raspberry-pi-official-case\/\" target=\"_blank\">assemble the Raspberry Pi 3 board to the Official Raspberry Pi case<\/a>.<\/p>\n<h2>Starting the Raspbian Stretch Lite operating system<\/h2>\n<p>With the assembly of your Raspberry Pi 3 board and Official Raspberry Pi case, connect one end of the RJ45 cable to the RJ45 port on the Raspberry Pi 3 board and the other end of the cable to one of the switch port of your <a href=\"https:\/\/www.amazon.com\/s\/ref=as_li_ss_tl?url=search-alias=aps&field-keywords=home+router&linkCode=ll2&tag=clivsperswebs-20&linkId=dd988f9e10e1a419b9d518690e9c8cd8\" target=\"_blank\">home router<\/a>. After that, connect the micro USB power supply to the Raspberry Pi 3 board and a wall socket. Turn on the power socket to supply power to the Raspberry Pi 3 board.<\/p>\n<h2>Changing default password, Locale and Timezone of your Raspbian Stretch Lite<\/h2>\n<p>There are a few configurations that you should perform on the first run of your Raspbian Stretch Lite. Proceed on to <a href=\"https:\/\/www.techcoil.com\/blog\/set-of-configurations-to-perform-on-the-first-run-of-your-raspbian-stretch-lite\/\" rel=\"noopener\" target=\"_blank\">change the default password, Locale and Timezone of your Raspbian Stretch Lite<\/a>.  <\/p>\n<h2>Checking if Python 3 is included in Raspbian Stretch Lite by default<\/h2>\n<p>Raspbian Stretch Lite includes Python 3 by default. We can verify that by running the following command:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\ndpkg --get-selections | grep python3\r\n<\/pre>\n<p>which returns the following output:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nlibpython3-stdlib:armhf\t\t\t\tinstall\r\nlibpython3.5:armhf\t\t\t\tinstall\r\nlibpython3.5-minimal:armhf\t\t\tinstall\r\nlibpython3.5-stdlib:armhf\t\t\tinstall\r\npython3\t\t\t\t\t\tinstall\r\npython3-apt\t\t\t\t\tinstall\r\npython3-minimal\t\t\t\t\tinstall\r\npython3.5\t\t\t\t\tinstall\r\npython3.5-minimal\t\t\t\tinstall\r\n<\/pre>\n<h2>Installing Python 3 package manager (pip3) on Raspbian Stretch Lite<\/h3>\n<p>This version of Raspbian Stretch Lite did not install the Python 3 Package Manager by default. The Python 3 package manager will be useful for managing the dependencies for your Python 3 applications. As such, proceed to install the Python 3 Package Manager on Raspberry Stretch Lite.<\/p>\n<p>To install the Python 3 Package Manager, run the following command:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nsudo apt-get install python3-pip -y\r\n<\/pre>\n<p>Once the Python 3 package manager is successfully installed, you can run the following command to see the Python 3 Packages that are available in the system:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\npip3 list\r\n<\/pre>\n<p>Running the command can show output similar to the following:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\ncryptography (1.7.1)\r\nidna (2.2)\r\nkeyring (10.1)\r\nkeyrings.alt (1.3)\r\npip (9.0.1)\r\npyasn1 (0.1.9)\r\npycrypto (2.6.1)\r\npygobject (3.22.0)\r\npython-apt (1.1.0b5)\r\npyxdg (0.25)\r\nSecretStorage (2.3.1)\r\nsetuptools (33.1.1)\r\nsix (1.10.0)\r\nwheel (0.29.0)\r\n<\/pre>\n<h2>Installing Virtualenv on Raspbian Stretch Lite<\/h2>\n<p><a href=\"https:\/\/virtualenv.pypa.io\/en\/stable\/\" rel=\"noopener\" target=\"_blank\">Virtualenv<\/a> is a tool that allows us to create isolated environments in the same machine. This is useful if you have to run multiple applications with conflicting python dependencies on your Raspberry Pi 3.<\/p>\n<p>To install Virtualenv, I run the following command:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nsudo apt-get install virtualenv -y\r\n<\/pre>\n<h2>Buying your Raspberry Pi 3 components from Amazon<\/h2>\n<p>If you do not have the Raspberry Pi 3 components mentioned in this post yet, you may want to purchase them from Amazon. Simply click on the button below to add the Raspberry Pi 3 components to your cart. You may remove anything that you already have or replace some of the components with other components.<\/p>\n<p><center><\/p>\n<form action=\"https:\/\/www.amazon.com\/gp\/aws\/cart\/add.html\" method=\"GET\" target=\"_blank\"><input name=\"AssociateTag\" type=\"hidden\" value=\"clivsperswebs-20\"><input name=\"SubscriptionId\" type=\"hidden\" value=\"[AKIAIMND5UBCQU2HRSUA]\"><input name=\"ASIN.1\" type=\"hidden\" value=\"B07BC6WH7V\"><input name=\"Quantity.1\" type=\"hidden\" value=\"1\"><input name=\"ASIN.2\" type=\"hidden\" value=\"B01F1PSFY6\"><input name=\"Quantity.2\" type=\"hidden\" value=\"1\"><input name=\"ASIN.3\" type=\"hidden\" value=\"B073JWXGNT\"><input name=\"Quantity.3\" type=\"hidden\" value=\"1\"><input name=\"ASIN.4\" type=\"hidden\" value=\"B00N2VISLW\"><input name=\"Quantity.4\" type=\"hidden\" value=\"1\"><br \/>\n<input alt=\"Buy from Amazon.com\" name=\"add\" type=\"image\" src=\"https:\/\/images-na.ssl-images-amazon.com\/images\/G\/01\/associates\/remote-buy-box\/buy4.gif\" value=\"Buy from Amazon.com\"><\/form>\n<p><\/center><\/p>\n\n      <ul id=\"social-sharing-buttons-list\">\n        <li class=\"facebook\">\n          <a href=\"https:\/\/www.facebook.com\/sharer\/sharer.php?u=https%3A%2F%2Fwp.me%2Fp245TQ-7W\" target=\"_blank\" role=\"button\" rel=\"nofollow\">\n            <img decoding=\"async\" src=\"\/ph\/img\/3rd-party\/social-icons\/Facebook.png\" alt=\"Facebook icon\"> Share\n          <\/a>\n        <\/li>\n        <li class=\"twitter\">\n          <a href=\"https:\/\/twitter.com\/intent\/tweet?text=&url=https%3A%2F%2Fwp.me%2Fp245TQ-7W&via=Techcoil_com\" target=\"_blank\" role=\"button\" rel=\"nofollow\">\n          <img decoding=\"async\" src=\"\/ph\/img\/3rd-party\/social-icons\/Twitter.png\" alt=\"Twitter icon\"> Tweet\n          <\/a>\n        <\/li>\n        <li class=\"linkedin\">\n          <a href=\"https:\/\/www.linkedin.com\/shareArticle?mini=1&title=&url=https%3A%2F%2Fwp.me%2Fp245TQ-7W&source=https:\/\/www.techcoil.com\" target=\"_blank\" role=\"button\" rel=\"nofollow\">\n          <img decoding=\"async\" src=\"\/ph\/img\/3rd-party\/social-icons\/linkedin.png\" alt=\"Linkedin icon\"> Share\n          <\/a>\n        <\/li>\n        <li class=\"pinterest\">\n          <a href=\"https:\/\/pinterest.com\/pin\/create\/button\/?url=https%3A%2F%2Fwww.techcoil.com%2Fblog%2Fwp-json%2Fwp%2Fv2%2Fposts%2F492&description=\" class=\"pin-it-button\" target=\"_blank\" role=\"button\" rel=\"nofollow\" count-layout=\"horizontal\">\n          <img decoding=\"async\" src=\"\/ph\/img\/3rd-party\/social-icons\/Pinterest.png\" alt=\"Pinterest icon\"> Save\n          <\/a>\n        <\/li>\n      <\/ul>\n    ","protected":false},"excerpt":{"rendered":"<p><a href=\"https:\/\/www.raspbian.org\/\" rel=\"noopener\" target=\"_blank\">Raspbian<\/a> Stretch Lite operating system is the <a href=\"https:\/\/www.raspberrypi.org\/\" rel=\"noopener\" target=\"_blank\">Raspberry Pi<\/a> Foundation&#8217;s official supported operating system for running headless software. It is a good operating system for different Raspberry Pi 3 use cases. Some examples include:<\/p>\n<ul>\n<li><a href=\"https:\/\/www.techcoil.com\/blog\/how-i-setup-jenkins-on-my-raspberry-pi-3-with-raspbian-stretch-lite\/\">Jenkins for automating repetitive tasks.<\/a><\/li>\n<li><a href=\"https:\/\/www.techcoil.com\/blog\/setting-up-wordpress-on-raspberry-pi-3-with-raspbian-stretch-lite-nginx-mariadb-and-php-7-as-the-lemp-stack\/\" rel=\"noopener\" target=\"_blank\">Wordpress site for personal blog<\/a><\/li>\n<\/ul>\n<p>If you are planning to use Raspberry Pi 3 GPIO to interface with the real world, it is recommended that you setup Raspbian Stretch Lite to run Python 3 applications. <\/p>\n<p>This post provides the steps to setup Raspbian Stretch Lite on Raspberry Pi 3 for running Python 3 applications.<\/p>\n","protected":false},"author":1,"featured_media":691,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"advanced_seo_description":"","jetpack_seo_html_title":"","jetpack_seo_noindex":false,"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"footnotes":""},"categories":[4],"tags":[484,226,233,240,308,412,445,279,195,426],"jetpack_featured_media_url":"https:\/\/www.techcoil.com\/blog\/wp-content\/uploads\/raspberry-pi-3-board-fitted-into-red-base-of-official-case.jpg","jetpack_shortlink":"https:\/\/wp.me\/p245TQ-7W","jetpack-related-posts":[],"jetpack_likes_enabled":true,"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.techcoil.com\/blog\/wp-json\/wp\/v2\/posts\/492"}],"collection":[{"href":"https:\/\/www.techcoil.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.techcoil.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.techcoil.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.techcoil.com\/blog\/wp-json\/wp\/v2\/comments?post=492"}],"version-history":[{"count":0,"href":"https:\/\/www.techcoil.com\/blog\/wp-json\/wp\/v2\/posts\/492\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.techcoil.com\/blog\/wp-json\/wp\/v2\/media\/691"}],"wp:attachment":[{"href":"https:\/\/www.techcoil.com\/blog\/wp-json\/wp\/v2\/media?parent=492"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.techcoil.com\/blog\/wp-json\/wp\/v2\/categories?post=492"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.techcoil.com\/blog\/wp-json\/wp\/v2\/tags?post=492"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}