{"id":50,"date":"2018-10-12T03:02:55","date_gmt":"2018-10-12T03:02:55","guid":{"rendered":"http:\/\/wcwp.rf.gd\/2018\/10\/12\/https-landscapearchaeology-org-2018-installing-python-packages-in-qgis-3-for-windows\/"},"modified":"2018-10-12T03:02:55","modified_gmt":"2018-10-12T03:02:55","slug":"installing-python-packages-in-qgis-3-for-windows","status":"publish","type":"post","link":"https:\/\/landscapeanalysis.org\/?p=50","title":{"rendered":"Installing Python packages in QGIS 3 (for Windows)"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Python is in the heart of QGIS (or in the guts if you prefer), which enables us to use tons of third party Python libraries. In Linux systems, QGIS will use the main Python installation, but in Windows things get more complicated. QGIS has it\u2019s own Python, which means we end up with various Pythons on our machines\u2026<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This is how to proceed in QGIS 3.x in Windows (I work on Win. 7)<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Open OSGeo4W shell (packed with QGIS in the start menu)<\/li>\n\n\n\n<li>Type <code class=\"language-python highlighter-rouge\"><span class=\"n\">py3_env<\/span><\/code>. This should print paths of your QGIS Python installation. [<strong>Not required for newer QGIS versions<\/strong>]<\/li>\n\n\n\n<li>Use Python\u2019s <code class=\"language-python highlighter-rouge\"><span class=\"n\">pip<\/span><\/code> to install the library of your choice: <code class=\"language-python highlighter-rouge\"><span class=\"n\">python<\/span> <span class=\"o\">-<\/span><span class=\"n\">m<\/span> <span class=\"n\">pip<\/span> <span class=\"n\">install<\/span> <span class=\"p\">{<\/span><span class=\"n\">your<\/span> <span class=\"n\">library<\/span><span class=\"p\">}<\/span><\/code><\/li>\n<\/ol>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"http:\/\/landscapearchaeology.org\/wp\/wp-content\/uploads\/figures-jekyll\/2018\/10\/Capture.png\"><img decoding=\"async\" src=\"http:\/\/landscapearchaeology.org\/wp-content\/uploads\/figures-jekyll\/2018\/10\/Capture.png\" alt=\"\"\/><\/a><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Remark: I don\u2019t need to open the shell as administrator \u2013 but this could solve some problems if the program starts complaining about permissions.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Not working ?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Try <code>python -m ensurepip --upgrade<\/code> if it cannot find the pip module.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Option 2<\/strong> (not recomended)<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Packages can also be installed directly from within Python, but that is not the preferred approach. Open QGIS Python console (under Plugins&nbsp;\u00bb Python Console) and type:<\/p>\n\n\n\n<div class=\"language-python highlighter-rouge\">\n<div class=\"highlight\">\n<pre class=\"highlight\"><code><span class=\"o\">&gt;&gt;<\/span> <span class=\"kn\">import<\/span> <span class=\"nn\">pip<\/span>\n\n<span class=\"o\">&gt;&gt;<\/span> <span class=\"n\">pip<\/span><span class=\"p\">.<\/span><span class=\"n\">main<\/span><span class=\"p\">([<\/span><span class=\"s\">'install'<\/span><span class=\"p\">,<\/span> <span class=\"s\">'my-package-name'<\/span><span class=\"p\">])<\/span>\n\n<\/code><\/pre>\n<\/div>\n<\/div>\n\n\n\n<p class=\"wp-block-paragraph\">Note that the arguments are given as a list [\u2026] of \u2018strings\u2019.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Python is in the heart of QGIS (or in the guts if you prefer), which enables us to use tons of third party Python libraries. In Linux systems, QGIS will use the main Python installation, but in Windows things get more complicated. QGIS has it\u2019s own Python, which means we end up with various Pythons [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[11],"class_list":["post-50","post","type-post","status-publish","format-standard","hentry","category-uncategorized","tag-qgis"],"_links":{"self":[{"href":"https:\/\/landscapeanalysis.org\/index.php?rest_route=\/wp\/v2\/posts\/50","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/landscapeanalysis.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/landscapeanalysis.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/landscapeanalysis.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/landscapeanalysis.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=50"}],"version-history":[{"count":0,"href":"https:\/\/landscapeanalysis.org\/index.php?rest_route=\/wp\/v2\/posts\/50\/revisions"}],"wp:attachment":[{"href":"https:\/\/landscapeanalysis.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=50"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/landscapeanalysis.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=50"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/landscapeanalysis.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=50"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}