<div dir="ltr"><div><br></div>Modules are installed, but they are in a different directory than standard modules directory. I considered an option to add a site specific directory, but I want to make module path application specific rather than installing it in system-wide directory. virtualenv is one option, but that means anyone who wants to run this particular script will need to activate virtualenv each time. I thought allowing application to find/use it's dependencies would be easier. Are there any other options?</div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Jul 27, 2015 at 12:45 PM, Ned Batchelder <span dir="ltr"><<a href="mailto:ned@nedbatchelder.com" target="_blank">ned@nedbatchelder.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On Monday, July 27, 2015 at 1:24:50 PM UTC-4, neubyr wrote:<br>
> I am trying to understand sys.path working and best practices for managing it within a program or script. Is it fine to modify sys.path using sys.path.insert(0, EXT_MODULES_DIR)? One stackoverflow answer - <a href="http://stackoverflow.com/a/10097543" rel="noreferrer" target="_blank">http://stackoverflow.com/a/10097543</a> - suggests that it may break external 3'rd party code as by convention first item of sys.path list, path[0], is the directory containing the script that was used to invoke the Python interpreter. So what are best practices to prepend sys.path in the program itself? Any further elaboration would be helpful. <br>
<br>
</span>The best practice is not to modify sys.path at all, and instead to install<br>
modules you need to import.  That way they can be imported without resorting<br>
to sys.path fiddling in the first place.<br>
<br>
Is there a reason you can't install the modules? Maybe we can help solve that.<br>
<span class="HOEnZb"><font color="#888888"><br>
--Ned.<br>
<br>
--<br>
<a href="https://mail.python.org/mailman/listinfo/python-list" rel="noreferrer" target="_blank">https://mail.python.org/mailman/listinfo/python-list</a><br>
</font></span></blockquote></div><br></div>