<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Install python module from within script in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/install-python-module-from-within-script/m-p/487409#M38050</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Fantastic! Thanks mate, you've saved me hours of chaos and confusion.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 06 Jun 2016 23:26:23 GMT</pubDate>
    <dc:creator>AnthonyCheesman1</dc:creator>
    <dc:date>2016-06-06T23:26:23Z</dc:date>
    <item>
      <title>Install python module from within script</title>
      <link>https://community.esri.com/t5/python-questions/install-python-module-from-within-script/m-p/487405#M38046</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I've got a small project that I'm working on that requires installation of the dropbox Python library, as the script needs to a write files to it.&lt;/P&gt;&lt;P&gt;Ideally I'm going to deploy this to a number of users either via a toolbox or a Python add-in.&lt;/P&gt;&lt;P&gt;The catch is that dropbox is not a standard module, and at Python 2.7.5, pip (which I would normally use to install new module) is not a standard module either.&lt;/P&gt;&lt;P&gt;What I'm wondering is:&lt;/P&gt;&lt;P&gt;1/ how would I programatically go about installing a new module from inside a running script; or&lt;/P&gt;&lt;P&gt;2/ is there a way I can bundle the module either into my code, or as part of my code package ('bundle of files') so that the script can find and install the missing module?&lt;/P&gt;&lt;P&gt;3/ I posted a similar question on Reddit and it was suggested that I look at 'freezing' my code (effectively convert to an .exe) - but I'm unsure whether this will allow the script to interact with the toolbox to access parameters etc. Would compiling the code to a .pyc allow this to work?&lt;/P&gt;&lt;P&gt;Any and all help gratefully received!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 06 Jun 2016 09:50:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/install-python-module-from-within-script/m-p/487405#M38046</guid>
      <dc:creator>AnthonyCheesman1</dc:creator>
      <dc:date>2016-06-06T09:50:01Z</dc:date>
    </item>
    <item>
      <title>Re: Install python module from within script</title>
      <link>https://community.esri.com/t5/python-questions/install-python-module-from-within-script/m-p/487406#M38047</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You can distribute it with your code, i.e as a 'bundle of files'. The directory your script is in is part of the module search path - &lt;A href="https://docs.python.org/2/tutorial/modules.html#the-module-search-path" title="https://docs.python.org/2/tutorial/modules.html#the-module-search-path"&gt;6. Modules — Python 2.7.11 documentation&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So you would have something like:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;some_dir&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;+-- your_script.py&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;+-- dropbox&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif;"&gt;You can also modify the search path at runtime, i.e with&lt;/SPAN&gt; sys.path.append('path/to/folder/dropbox/is/in')&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 06 Jun 2016 10:09:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/install-python-module-from-within-script/m-p/487406#M38047</guid>
      <dc:creator>Luke_Pinner</dc:creator>
      <dc:date>2016-06-06T10:09:53Z</dc:date>
    </item>
    <item>
      <title>Re: Install python module from within script</title>
      <link>https://community.esri.com/t5/python-questions/install-python-module-from-within-script/m-p/487407#M38048</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Luke - really good information to know.&lt;/P&gt;&lt;P&gt;At the risk of sounding like a complete dumb-arse - what installer files would I need to put in that location for the dropbox module to work? As I installed the module via pip from the command line, I'm not sure what files actually contribute to the library.&lt;/P&gt;&lt;P&gt;In my C:\Python27\Lib\site-packages folder, I have a /dropbox and /dropbox-6.3.0.dist-info folders - do these constitute the module as such?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 06 Jun 2016 10:45:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/install-python-module-from-within-script/m-p/487407#M38048</guid>
      <dc:creator>AnthonyCheesman1</dc:creator>
      <dc:date>2016-06-06T10:45:24Z</dc:date>
    </item>
    <item>
      <title>Re: Install python module from within script</title>
      <link>https://community.esri.com/t5/python-questions/install-python-module-from-within-script/m-p/487408#M38049</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Just the dropbox directory. You'll also need the urllib3 and requests directories and six.py file as they're 3rd party libraries required by dropbox, see the "Requires Distributions" section in &lt;A href="https://pypi.python.org/pypi/dropbox/6.4.0" title="https://pypi.python.org/pypi/dropbox/6.4.0"&gt;dropbox 6.4.0 : Python Package Index&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 06 Jun 2016 21:16:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/install-python-module-from-within-script/m-p/487408#M38049</guid>
      <dc:creator>Luke_Pinner</dc:creator>
      <dc:date>2016-06-06T21:16:25Z</dc:date>
    </item>
    <item>
      <title>Re: Install python module from within script</title>
      <link>https://community.esri.com/t5/python-questions/install-python-module-from-within-script/m-p/487409#M38050</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Fantastic! Thanks mate, you've saved me hours of chaos and confusion.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 06 Jun 2016 23:26:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/install-python-module-from-within-script/m-p/487409#M38050</guid>
      <dc:creator>AnthonyCheesman1</dc:creator>
      <dc:date>2016-06-06T23:26:23Z</dc:date>
    </item>
    <item>
      <title>Re: Install python module from within script</title>
      <link>https://community.esri.com/t5/python-questions/install-python-module-from-within-script/m-p/487410#M38051</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Postscript to this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have tested Luke's proposed fix and it works.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;There were a couple of additional bits and bobs to copy in to get it to run, but I now have a script that is happily functioning on a clean install machine without have any external dependencies, which should also not cause any administrator type issues.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For future reference, I needed the following stored in the same folder as my .py file to get it functioning:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;dropbox (folder)&lt;/P&gt;&lt;P&gt;pip (folder)&lt;/P&gt;&lt;P&gt;pkg_resources (folder) (note: duplicate as also inside pip folder)&lt;/P&gt;&lt;P&gt;requests&lt;/P&gt;&lt;P&gt;urllib3&lt;/P&gt;&lt;P&gt;Also six.py (file) (note:duplicated as also inside pip folder)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Huge thanks to Luke. As to packaging and making pretty, I think this is going to have to live inside a Python add-in toolbar, so all the modules etc are packaged together in one location to allow full portability.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 07 Jun 2016 06:56:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/install-python-module-from-within-script/m-p/487410#M38051</guid>
      <dc:creator>AnthonyCheesman1</dc:creator>
      <dc:date>2016-06-07T06:56:21Z</dc:date>
    </item>
    <item>
      <title>Re: Install python module from within script</title>
      <link>https://community.esri.com/t5/python-questions/install-python-module-from-within-script/m-p/487411#M38052</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You don't need to put everything in a python add-in (unless you want to of course...).&amp;nbsp; You can still have all the supporting modules in a single folder.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How would you prefer to run your script? As a toolbox tool or an addin?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 07 Jun 2016 23:13:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/install-python-module-from-within-script/m-p/487411#M38052</guid>
      <dc:creator>Luke_Pinner</dc:creator>
      <dc:date>2016-06-07T23:13:52Z</dc:date>
    </item>
    <item>
      <title>Re: Install python module from within script</title>
      <link>https://community.esri.com/t5/python-questions/install-python-module-from-within-script/m-p/487412#M38053</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I think for portability and ease of use, I prefer the add-in option. The ability to deploy and install a single .addin file beats the pants off trying to manage the location of multiple files (especially when multiple users of varying technical abilities are involved). Add-in gives the option of the tool being run disconnected from our internal network as well.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If I'm really smart, I can add it as an additional tool to a python .addin toolbar I'm already using.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Could be a good tinkering job for this weekend.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 Jun 2016 06:53:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/install-python-module-from-within-script/m-p/487412#M38053</guid>
      <dc:creator>AnthonyCheesman1</dc:creator>
      <dc:date>2016-06-08T06:53:07Z</dc:date>
    </item>
    <item>
      <title>Re: Install python module from within script</title>
      <link>https://community.esri.com/t5/python-questions/install-python-module-from-within-script/m-p/487413#M38054</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Just curious, why did you need pip if you weren't installing any externals?&lt;/P&gt;&lt;P&gt;Just setting it up for future maybes?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 Jun 2016 21:22:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/install-python-module-from-within-script/m-p/487413#M38054</guid>
      <dc:creator>PaulDavidson1</dc:creator>
      <dc:date>2016-06-08T21:22:03Z</dc:date>
    </item>
    <item>
      <title>Re: Install python module from within script</title>
      <link>https://community.esri.com/t5/python-questions/install-python-module-from-within-script/m-p/487414#M38055</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Paul, can't give you a definitive answer on that other than I think it's one of the dependencies - which I found out when I got an error message of the effect of pip not being available. Once I dropped the pip directory in the same folder, it worked.&lt;/P&gt;&lt;P&gt;Whether or not it needs the whole module or not I don't know - but I'm putting this in the category of 'it's working - I don't know why - but I won't mess with it any more'.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 Jun 2016 21:49:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/install-python-module-from-within-script/m-p/487414#M38055</guid>
      <dc:creator>AnthonyCheesman1</dc:creator>
      <dc:date>2016-06-08T21:49:14Z</dc:date>
    </item>
    <item>
      <title>Re: Install python module from within script</title>
      <link>https://community.esri.com/t5/python-questions/install-python-module-from-within-script/m-p/487415#M38056</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Interesting...&amp;nbsp; Sounds like something either is using a dependency in pip or might use pip to install missing dependencies or...&amp;nbsp; Regardless, it works which is what matters.&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thanks. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 Jun 2016 21:52:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/install-python-module-from-within-script/m-p/487415#M38056</guid>
      <dc:creator>PaulDavidson1</dc:creator>
      <dc:date>2016-06-08T21:52:45Z</dc:date>
    </item>
    <item>
      <title>Re: Install python module from within script</title>
      <link>https://community.esri.com/t5/python-questions/install-python-module-from-within-script/m-p/487416#M38057</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;For those still interested in this - Dropbox has now upgraded it's API to v2. This has meant updating the module install (no problems there).&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 04 Jul 2016 06:54:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/install-python-module-from-within-script/m-p/487416#M38057</guid>
      <dc:creator>AnthonyCheesman1</dc:creator>
      <dc:date>2016-07-04T06:54:45Z</dc:date>
    </item>
  </channel>
</rss>

