{"id":348,"date":"2013-02-01T17:49:37","date_gmt":"2013-02-01T17:49:37","guid":{"rendered":"http:\/\/www.jontrinder.com\/blog\/?p=348"},"modified":"2013-02-03T10:34:41","modified_gmt":"2013-02-03T10:34:41","slug":"pyinstaller-matplotlib-and-basemap","status":"publish","type":"post","link":"https:\/\/www.jontrinder.com\/blog\/?p=348","title":{"rendered":"Pyinstaller, Matplotlib and BaseMap"},"content":{"rendered":"<p>Having big problems persuading a python,matplotlib and Basemap project to freeze using Pyinstaller.<\/p>\n<p>On doze and Linux,<\/p>\n<p>Basemap kept looking in the site\u00a0distribution\u00a0for the data files.<\/p>\n<p>Workround I found was the addition of this\u00a0environment\u00a0variable PROJ_DIR\u00a0via a tweak to proj.py<br \/>\nas per this post\u00a0<a href=\"http:\/\/code.google.com\/p\/pyproj\/issues\/detail?id=40&amp;q=PROJ_DIR\">http:\/\/code.google.com\/p\/pyproj\/issues\/detail?id=40&amp;q=PROJ_DIR<\/a><\/p>\n<p>Which boils down to around line 239, replace this line<\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">\r\n\r\npyproj_datadir = '\/usr\/share\/basemap\/data'\r\n\r\n<\/pre>\n<p>with<\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">\r\nif 'PROJ_DIR' in os.environ:\r\n   pyproj_datadir = os.environ&#x5B;'PROJ_DIR']\r\nelse:\r\n    pyproj_datadir = os.sep.join(&#x5B;os.path.dirname(__file__), 'data'])\r\n<\/pre>\n<p>I still needed to copy the mpl_tools folder across top where the pyinstaller produced single file executable was stored.<\/p>\n<p>Then set these env variables as always ymmv<\/p>\n<p>(looking round in basemaps proj.py and pyproj.py for where folders get set can be fruitful )as well)<\/p>\n<p>I will document this more fully sometime,along with all the useful links I found on the way meantime this may help you get working<\/p>\n<p>set BASEMAPDATA=p:\\dist\\mpl_toolkits\\basemap\\data<\/p>\n<p>set PROJ_DIR=P:\\dist\\mpl_toolkits\\basemap\\data<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Having big problems persuading a python,matplotlib and Basemap project to freeze using Pyinstaller. On doze and Linux, Basemap kept looking in the site\u00a0distribution\u00a0for the data files. Workround I found was the addition of this\u00a0environment\u00a0variable PROJ_DIR\u00a0via a tweak to proj.py as &hellip; <a href=\"https:\/\/www.jontrinder.com\/blog\/?p=348\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[81,79,48,47],"tags":[49,84,50],"class_list":["post-348","post","type-post","status-publish","format-standard","hentry","category-coding","category-linux","category-matplotlib","category-pandas","tag-basemap","tag-matplotlib","tag-python"],"_links":{"self":[{"href":"https:\/\/www.jontrinder.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/348","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.jontrinder.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.jontrinder.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.jontrinder.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.jontrinder.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=348"}],"version-history":[{"count":4,"href":"https:\/\/www.jontrinder.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/348\/revisions"}],"predecessor-version":[{"id":350,"href":"https:\/\/www.jontrinder.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/348\/revisions\/350"}],"wp:attachment":[{"href":"https:\/\/www.jontrinder.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=348"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.jontrinder.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=348"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.jontrinder.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=348"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}