<div dir="ltr">e.g.<div><a href="http://stackoverflow.com/questions/14050281/how-to-check-if-a-python-module-exists-without-importing-it">http://stackoverflow.com/questions/14050281/how-to-check-if-a-python-module-exists-without-importing-it</a><br></div></div><div class="gmail_extra"><br clear="all"><div><div class="gmail_signature">Luigi Pirelli<br><br>**************************************************************************************************<br>* Boundless QGIS Support/Development: lpirelli AT boundlessgeo DOT com<br>* LinkedIn: <a href="https://www.linkedin.com/in/luigipirelli" target="_blank">https://www.linkedin.com/in/luigipirelli</a><br>* Stackexchange: <a href="http://gis.stackexchange.com/users/19667/luigi-pirelli" target="_blank">http://gis.stackexchange.com/users/19667/luigi-pirelli</a><br>* GitHub: <a href="https://github.com/luipir" target="_blank">https://github.com/luipir</a><br>* Mastering QGIS: <a href="https://www.packtpub.com/application-development/mastering-qgis" target="_blank">https://www.packtpub.com/application-development/mastering-qgis</a><br>**************************************************************************************************</div></div>
<br><div class="gmail_quote">On 15 January 2016 at 13:24, Luigi Pirelli <span dir="ltr"><<a href="mailto:luipir@gmail.com" target="_blank">luipir@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">btw an exception can be caouse by other dependencies of openpyxl => better to check the correct exception than a generic one</div><div class="gmail_extra"><span class=""><br clear="all"><div><div>Luigi Pirelli<br><br>**************************************************************************************************<br>* Boundless QGIS Support/Development: lpirelli AT boundlessgeo DOT com<br>* LinkedIn: <a href="https://www.linkedin.com/in/luigipirelli" target="_blank">https://www.linkedin.com/in/luigipirelli</a><br>* Stackexchange: <a href="http://gis.stackexchange.com/users/19667/luigi-pirelli" target="_blank">http://gis.stackexchange.com/users/19667/luigi-pirelli</a><br>* GitHub: <a href="https://github.com/luipir" target="_blank">https://github.com/luipir</a><br>* Mastering QGIS: <a href="https://www.packtpub.com/application-development/mastering-qgis" target="_blank">https://www.packtpub.com/application-development/mastering-qgis</a><br>**************************************************************************************************</div></div>
<br></span><div><div class="h5"><div class="gmail_quote">On 15 January 2016 at 13:23, Luigi Pirelli <span dir="ltr"><<a href="mailto:luipir@gmail.com" target="_blank">luipir@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">thank you for sharing</div><div class="gmail_extra"><span><br clear="all"><div><div>Luigi Pirelli<br><br>**************************************************************************************************<br>* Boundless QGIS Support/Development: lpirelli AT boundlessgeo DOT com<br>* LinkedIn: <a href="https://www.linkedin.com/in/luigipirelli" target="_blank">https://www.linkedin.com/in/luigipirelli</a><br>* Stackexchange: <a href="http://gis.stackexchange.com/users/19667/luigi-pirelli" target="_blank">http://gis.stackexchange.com/users/19667/luigi-pirelli</a><br>* GitHub: <a href="https://github.com/luipir" target="_blank">https://github.com/luipir</a><br>* Mastering QGIS: <a href="https://www.packtpub.com/application-development/mastering-qgis" target="_blank">https://www.packtpub.com/application-development/mastering-qgis</a><br>**************************************************************************************************</div></div>
<br></span><div><div><div class="gmail_quote">On 15 January 2016 at 12:12, Pablo Fernández Moniz <span dir="ltr"><<a href="mailto:pablofernandezmoniz@gmail.com" target="_blank">pablofernandezmoniz@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><span style="font-size:13px">First of all, thank you very much for all the fast replies, they have been very helpful for us.</span><br><div><div style="font-size:13px"><div><div><div><br></div> The solution we finally implemented was adding the .egg file for the dependency and loading it when the wider system import fails in the following fashion:<br><br><span style="font-family:monospace,monospace">import os <br>import sys <br> <br>try: <br>    import openpyxl <br>except: <br>    package_name = "openpyxl-2.3.2-py2.7.egg" <br>    package_path = os.path.join(os.path.dirname(__file__), package_name) <br>    sys.path.append(package_path) <br>    import openpyxl</span><br><br></div> This may not be a solution for every use case but it gets the job done for us in our setup.<br><br></div> Once again, thank you for he fast replies and ideas given.<br></div><div style="font-size:13px"><br></div><span style="font-size:13px"> Kind regards,</span><br></div></div><div><div><div class="gmail_extra"><br><div class="gmail_quote">2016-01-15 4:40 GMT+00:00 Andreas Neumann <span dir="ltr"><<a href="mailto:a.neumann@carto.net" target="_blank">a.neumann@carto.net</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
  
    
  
  <div text="#000000" bgcolor="#FFFFFF">
    Note that the Windows binaries already contain xlwt and xlrd. Jürgen
    was so kind to include it, because I needed it as well for my
    plugins. Not sure about openpyxl. On Linux systems it is rather easy
    to install them through apt-get, pip or similar mechanisms. Just
    tell your users that/how they need/can install them.<span><font color="#888888"><br>
    <br>
    Andreas</font></span><div><div><br>
    <br>
    <div>On 14.01.2016 22:13, Matthias Kuhn
      wrote:<br>
    </div>
    <blockquote type="cite">
      
      Hi Pablo, Tim<br>
      <br>
      <div>On 01/14/2016 10:00 PM, Tim Sutton
        wrote:<br>
      </div>
      <blockquote type="cite">
        
        Hi
        <div><br>
          <div>
            <blockquote type="cite">
              <div>On 14 Jan 2016, at 18:06, Pablo Fernández
                Moniz <<a href="mailto:pablofernandezmoniz@gmail.com" target="_blank">pablofernandezmoniz@gmail.com</a>>

                wrote:</div>
              <br>
              <div>
                <div dir="ltr"><span style="font-size:13px">Hi!</span><br>
                  <div>
                    <div style="font-size:13px">
                      <div>
                        <div><br>
                        </div>
                         We are currently developing a QGIS plugin were
                        we wish to generate some Excel files as output. <br>
                        <br>
                         In order to build the spreadsheet file we need
                        to use some python modules installed from pip
                        (openpyxl, xlwt, etc). This dependency will
                        force every user to manually install the needed
                        package form the pip repository.<br>
                        <br>
                      </div>
                       This situation leaves us with the following
                      question: is possible or it will be in the future
                      to manage this kind of dependencies from QGIS side
                      when the user installs the plugin? <br>
                    </div>
                  </div>
                </div>
              </div>
            </blockquote>
            <div><br>
            </div>
            <div>Although it has been discussed and some prototyping was
              done to support automatic installation of dependencies at
              the last hackfest, there isn’t anything in the released
              versions of QGIS to support this yet. If your packages
              have no operating system specific binaries in them, then I
              suggest to bundle them into your plugin and use an
              appropriate import path relative to your code. Note there
              is a limit on how big your plugin can be (I think it is
              10mb) so you need to ensure your 3rd party deps do not
              bulk out your plugin too much.</div>
          </div>
        </div>
      </blockquote>
      <br>
      We bundled xlwt and xlrd as .egg with a plugin recently:<br>
      <br>
      <a href="https://github.com/opengisch/shpsync/blob/master/xlwt-1.0.0-py2.7.egg" target="_blank">https://github.com/opengisch/shpsync/blob/master/xlwt-1.0.0-py2.7.egg</a><br>
      <a href="https://github.com/opengisch/shpsync/blob/master/xlrd-0.9.4-py2.7.egg" target="_blank">https://github.com/opengisch/shpsync/blob/master/xlrd-0.9.4-py2.7.egg</a><br>
      <br>
      Until there's a cross-platform dependency management (which I know
      that several people are looking into) that's the safest road to
      follow.<br>
      <br>
      Best<br>
      <br>
      Matthias<br>
      <br>
      <blockquote type="cite">
        <div>
          <div>
            <div><br>
            </div>
            <div>Regards</div>
            <div><br>
            </div>
            <div>Tim</div>
            <br>
            <blockquote type="cite">
              <div>
                <div dir="ltr">
                  <div>
                    <div style="font-size:13px"><br>
                    </div>
                    <span style="font-size:13px"> Thank you for
                      your time! </span><br style="font-size:13px">
                    <br style="font-size:13px">
                    <span style="font-size:13px"> Kind regards.</span><br>
                  </div>
                  <div><span style="font-size:13px"><br>
                    </span></div>
                  -- <br>
                  <div>
                    <div dir="ltr">
                      <div>
                        <div><br>
                          Pablo Fernández Moniz<br>
                        </div>
                        GIT Analyst<br>
                        <br>
                      </div>
                      <a href="http://www.pablofm.com/" target="_blank">Web</a>    <a href="http://www.linkedin.com/in/pablofernandezmoniz/" target="_blank">Linkedin</a>   <a href="http://www.twitter.com/monizpablo" target="_blank">Twitter</a><br>
                    </div>
                  </div>
                </div>
                _______________________________________________<br>
                Qgis-developer mailing list<br>
                <a href="mailto:Qgis-developer@lists.osgeo.org" target="_blank">Qgis-developer@lists.osgeo.org</a><br>
                List info: <a href="http://lists.osgeo.org/mailman/listinfo/qgis-developer" target="_blank">http://lists.osgeo.org/mailman/listinfo/qgis-developer</a><br>
                Unsubscribe: <a href="http://lists.osgeo.org/mailman/listinfo/qgis-developer" target="_blank">http://lists.osgeo.org/mailman/listinfo/qgis-developer</a></div>
            </blockquote>
          </div>
          <br>
          <div>
            <div style="color:rgb(0,0,0);font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-align:center"><span>—</span></div>
            <div style="color:rgb(0,0,0);font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-align:center"><span><br>
              </span></div>
            <span style="color:rgb(0,0,0);font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><br>
              <span><img height="66" width="160"></span>
              <div style="color:rgb(0,0,0);font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-align:center"><br>
                <br>
              </div>
              <div style="color:rgb(0,0,0);font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-align:center">Tim Sutton</div>
              <div style="color:rgb(0,0,0);font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-align:center"><br>
              </div>
              <div style="color:rgb(0,0,0);font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">
                <div style="text-align:center">Visit <a href="http://kartoza.com" target="_blank"></a><a href="http://kartoza.com" target="_blank">http://kartoza.com</a> to
                  find out about open source:</div>
                <div style="text-align:center"><br>
                </div>
                <div>
                  <div style="text-align:center">* Desktop
                    GIS programming services</div>
                  <div style="text-align:center">* Geospatial
                    web development</div>
                  <div style="text-align:center">* GIS
                    Training</div>
                  <div style="text-align:center">* Consulting
                    Services</div>
                  <div style="text-align:center"><br>
                  </div>
                  <div>
                    <div style="text-align:center">Skype:
                      timlinux Irc: timlinux on #qgis at <a href="http://freenode.net" target="_blank">freenode.net</a></div>
                    <div style="text-align:center">Tim is a
                      member of the QGIS Project Steering Committee</div>
                    <div style="text-align:center"><br>
                    </div>
                    <div style="text-align:center">Kartoza is
                      a merger between Linfiniti and Afrispatial</div>
                  </div>
                </div>
              </div>
            </span></div>
          <br>
        </div>
        <br>
        <fieldset></fieldset>
        <br>
        <pre>_______________________________________________
Qgis-developer mailing list
<a href="mailto:Qgis-developer@lists.osgeo.org" target="_blank">Qgis-developer@lists.osgeo.org</a>
List info: <a href="http://lists.osgeo.org/mailman/listinfo/qgis-developer" target="_blank">http://lists.osgeo.org/mailman/listinfo/qgis-developer</a>
Unsubscribe: <a href="http://lists.osgeo.org/mailman/listinfo/qgis-developer" target="_blank">http://lists.osgeo.org/mailman/listinfo/qgis-developer</a></pre>
      </blockquote>
      <br>
      <pre cols="72">-- 
Matthias Kuhn
OPENGIS.ch - <a href="https://www.opengis.ch" target="_blank">https://www.opengis.ch</a>
Spatial • (Q)GIS • PostGIS • Open Source</pre>
      <br>
      <fieldset></fieldset>
      <br>
      <pre>_______________________________________________
Qgis-developer mailing list
<a href="mailto:Qgis-developer@lists.osgeo.org" target="_blank">Qgis-developer@lists.osgeo.org</a>
List info: <a href="http://lists.osgeo.org/mailman/listinfo/qgis-developer" target="_blank">http://lists.osgeo.org/mailman/listinfo/qgis-developer</a>
Unsubscribe: <a href="http://lists.osgeo.org/mailman/listinfo/qgis-developer" target="_blank">http://lists.osgeo.org/mailman/listinfo/qgis-developer</a></pre>
    </blockquote>
    <br>
  </div></div></div>

<br>_______________________________________________<br>
Qgis-developer mailing list<br>
<a href="mailto:Qgis-developer@lists.osgeo.org" target="_blank">Qgis-developer@lists.osgeo.org</a><br>
List info: <a href="http://lists.osgeo.org/mailman/listinfo/qgis-developer" rel="noreferrer" target="_blank">http://lists.osgeo.org/mailman/listinfo/qgis-developer</a><br>
Unsubscribe: <a href="http://lists.osgeo.org/mailman/listinfo/qgis-developer" rel="noreferrer" target="_blank">http://lists.osgeo.org/mailman/listinfo/qgis-developer</a><br></blockquote></div><br><br clear="all"><div><br></div>-- <br><div><div dir="ltr"><div><div><br>Pablo Fernández Moniz<br></div>GIT Analyst<br><br></div><a href="http://www.pablofm.com" target="_blank">Web</a>    <a href="http://www.linkedin.com/in/pablofernandezmoniz/" target="_blank">Linkedin</a>   <a href="http://www.twitter.com/monizpablo" target="_blank">Twitter</a><br></div></div>
</div>
</div></div><br>_______________________________________________<br>
Qgis-developer mailing list<br>
<a href="mailto:Qgis-developer@lists.osgeo.org" target="_blank">Qgis-developer@lists.osgeo.org</a><br>
List info: <a href="http://lists.osgeo.org/mailman/listinfo/qgis-developer" rel="noreferrer" target="_blank">http://lists.osgeo.org/mailman/listinfo/qgis-developer</a><br>
Unsubscribe: <a href="http://lists.osgeo.org/mailman/listinfo/qgis-developer" rel="noreferrer" target="_blank">http://lists.osgeo.org/mailman/listinfo/qgis-developer</a><br></blockquote></div><br></div></div></div>
</blockquote></div><br></div></div></div>
</blockquote></div><br></div>