{"id":5606,"date":"2018-06-05T23:49:04","date_gmt":"2018-06-05T21:49:04","guid":{"rendered":"https:\/\/michlstechblog.info\/blog\/?p=5606"},"modified":"2018-06-06T09:04:51","modified_gmt":"2018-06-06T07:04:51","slug":"python-install-python-with-pip-on-windows-by-the-embeddable-zip-file","status":"publish","type":"post","link":"https:\/\/michlstechblog.info\/blog\/python-install-python-with-pip-on-windows-by-the-embeddable-zip-file\/","title":{"rendered":"Python: Install Python with pip on Windows by the embeddable zip file"},"content":{"rendered":"<div class=\"twoclick_social_bookmarks_post_5606 social_share_privacy clearfix 1.6.4 locale-en_US sprite-en_US\"><\/div><div class=\"twoclick-js\"><script type=\"text\/javascript\">\/* <![CDATA[ *\/\njQuery(document).ready(function($){if($('.twoclick_social_bookmarks_post_5606')){$('.twoclick_social_bookmarks_post_5606').socialSharePrivacy({\"services\":{\"flattr\":{\"uid\":\"Michl\",\"status\":\"on\",\"the_title\":\"Python%3A%20Install%20Python%20with%20pip%20on%20Windows%20by%20the%20embeddable%20zip%20file\",\"the_excerpt\":\"Hi%2C%0D%0A%0D%0Ato%20install%20Python%20on%20Windows%20download%20the%20latest%20version.%20In%20this%20example%20Python%203.6.5.%0D%0A%0D%0AExtract%20the%20zip%20file%20to%20an%20directory%2C%20%20e.g.%20D%3A%5Cpython3.6.5.%0D%0A%20%28more%26hellip%3B%29\",\"txt_info\":\"2 clicks for more data protection:\\r\\n\\r\\nOnly when you click here, the button will be come active and you can send your recommendation to Flattr. When activating, data are transmitted to third parties. \",\"perma_option\":\"off\"}},\"txt_help\":\"When you activate these fields by clicking, information to Flattr may be transferred abroad, and probably may also stored there.\",\"settings_perma\":\"Enable permanently and accept data transmission. \",\"info_link\":\"http:\\\/\\\/www.heise.de\\\/ct\\\/artikel\\\/2-Klicks-fuer-mehr-Datenschutz-1333879.html\",\"uri\":\"https:\\\/\\\/michlstechblog.info\\\/blog\\\/python-install-python-with-pip-on-windows-by-the-embeddable-zip-file\\\/\",\"post_id\":5606,\"post_title_referrer_track\":\"Python%3A+Install+Python+with+pip+on+Windows+by+the+embeddable+zip+file\",\"display_infobox\":\"on\"});}});\n\/* ]]> *\/<\/script><\/div><p>Hi,<\/p>\n<p>to install Python on Windows download the latest version. In this example <a href=\"https:\/\/www.python.org\/ftp\/python\/3.6.5\/python-3.6.5-embed-amd64.zip\">Python 3.6.5<\/a>.<\/p>\n<p>Extract the zip file to an directory,  e.g. D:\\python3.6.5.<br \/>\n<!--more--><br \/>\nTo install pip download the latest version of <a href=\"https:\/\/bootstrap.pypa.io\/get-pip.py\" rel=\"noopener\" target=\"_blank\">get-pip<\/a> to the pythons install path and start installation.<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nd:\\&gt; cd \/d D:\\Python3.6.5\r\nD:\\Python3.6.5&gt; python get-pip.py\r\n...\r\nInstalling collected packages: pip, setuptools, wheel\r\nSuccessfully installed pip-10.0.1 setuptools-39.2.0 wheel-0.31.1\r\n<\/pre>\n<p>If you are behind a proxy add the <strong>&#8211;proxy<\/strong> switch<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nD:\\Python3.6.5&gt; python get-pip.py --proxy=&quot;http:\/\/192.168.254.1:8888&quot;\r\n<\/pre>\n<p>Unfortunately in the default configuration you can not load any module installed by pip, pip itself too. Because the <strong>sys.path<\/strong> variable just contains Python Zip file and the path to the python directory where the python executable is located.<\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">\r\n&gt;&gt;&gt; import sys\r\n&gt;&gt;&gt; print(sys.path)\r\n&#x5B;'D:\\\\Python3.6.5\\\\python36.zip', 'D:\\\\Python3.6.5']\r\n&gt;&gt;&gt; import pip\r\nTraceback (most recent call last):\r\n  File &quot;&lt;stdin&gt;&quot;, line 1, in &lt;module&gt;\r\nModuleNotFoundError: No module named 'pip'\r\n<\/pre>\n<p>Any try to expand the variable by setting a <strong>PYTHONPATH <\/strong>variable are <strong>ignored<\/strong>. Root cause is that the embeddable zip file installation package contains a file <strong>python36._pth<\/strong> which overwrites all other possibilities to set the sys.path variable. sys.path contains all directories where python looks for modules.<\/p>\n<p>To set the sys.path variable open the _pth file an add the following pathes at the and of the file. Replace &#8220;D:\\Python3.6.5&#8221; with your installation directory.<br \/>\n<code><br \/>\nD:\\Python3.6.5<br \/>\nD:\\Python3.6.5\\DLLs<br \/>\nD:\\Python3.6.5\\lib<br \/>\nD:\\Python3.6.5\\lib\\plat-win<br \/>\nD:\\Python3.6.5\\lib\\site-packages<br \/>\n<\/code><\/p>\n<p>Or rename the python36._pth file <\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nD:\\Python3.6.5&gt; ren python36._pth python36._pth.save\r\n<\/pre>\n<p>and set the PYTHONPATH environment variable for the current user.<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nsetx PYTHONPATH &quot;D:\\Python3.6.5;D:\\Python3.6.5\\DLLs;D:\\Python3.6.5\\lib;D:\\Python3.6.5\\lib\\plat-win;D:\\Python3.6.5\\lib\\site-packages&quot;\r\n<\/pre>\n<p>or for the whole system<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nsetx \/M PYTHONPATH &quot;D:\\Python3.6.5;D:\\Python3.6.5\\DLLs;D:\\Python3.6.5\\lib;D:\\Python3.6.5\\lib\\plat-win;D:\\Python3.6.5\\lib\\site-packages&quot;\r\n<\/pre>\n<p>That&#8217;s it \ud83d\ude42<\/p>\n<p>Michael<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hi, to install Python on Windows download the latest version. In this example Python 3.6.5. Extract the zip file to an directory, e.g. D:\\python3.6.5.<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1200,2],"tags":[1202,119,1204,1203,1201,1205,1207,1206,20],"class_list":["post-5606","post","type-post","status-publish","format-standard","hentry","category-python","category-windows","tag-embeddable","tag-install","tag-modulenotfounderror","tag-no-module-named-pip","tag-python","tag-pythonpath","tag-pythonpath-ignored","tag-sys-path","tag-windows-2"],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/posts\/5606","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/comments?post=5606"}],"version-history":[{"count":16,"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/posts\/5606\/revisions"}],"predecessor-version":[{"id":5619,"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/posts\/5606\/revisions\/5619"}],"wp:attachment":[{"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/media?parent=5606"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/categories?post=5606"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/tags?post=5606"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}