Add user scripts folder to Maya
<p>I tried all methods explained on several documentation pages.</p>

<p>I modified the <strong>userSetup.mel</strong> file and it adds the folder with this code:</p>

<pre><code>string $s = `getenv MAYA_SCRIPT_PATH` + ";C:/MyScripts";
putenv "MAYA_SCRIPT_PATH" $s;
</code></pre>

<p>It didn't work. I also tried to do a "rehash" after doing putenv.</p>

<p>I removed that userSetup.mel file and modified the <strong>maya.env</strong> file using this other variable (since if I do this to MAYA_SCRIPT_PATH it breaks maya because overrides everything it had)</p>

<pre><code>USER_SCRIPT_PATH = C:/MyScripts
</code></pre>

<p>Anything works when I do "import folder" on a python tab. Folder is inside MyScripts folder, and there's a init file for all of them. It's not a python error, this folder works under maya/scripts folder.</p>

<p>It's not very clear why USER_SCRIPT_PATH is not mentioned anywhere in the docs as an official variable, no information about why any of those works. The folder ends up on the environment variable using getenv on MEL, but code is not loaded.</p>

<p>You don't want to set the environment variable after Maya is up and running, which is what you're doing in the mel example. You want it configured before maya starts looking for actual scripts.  In general most programs that use env vars read them at startup time and don't recognize changes made while the program is running -- thats why in Windows for example you need to restart your dos windows after changing an env var from the GUI.</p>

<p>Popular methods are:</p>

<ol>
<li>Launch from a .bat file which sets the var and then runs maya.  This lets you run multiple mayas side by side with different settings if needed</li>
<li>Do it with maya.env; this puts all the info into one place</li>
<li>For python, do it in <code>userSetup.py</code>.  @AriGold's example will work, although I prefer to use the <code>site</code> module and <code>site.addsitedir('path/to/someplace')</code> because you can use .pth files in your target directory to make it as complex as you need; see <a href="http://stackoverflow.com/questions/15208615/using-pth-files">this question</a> for more details about pth files.</li>
<li>use a <a href="http://theodox.github.io/2014/magical_modules" rel="nofollow">Maya module</a> which allows you to set not only script paths but all the other paths (bitmaps, plugins etc) in one go></li>
</ol>

python python-2.7 maya mel