What should be my python packages path?
<p>I'm on Mac OS X and I've heard that to avoid global installation of packages (using sudo) that might cause problems with the python files that OS X uses, the path to install python packages must be different than that of OS X. </p>

<p>Currently python executables are installed in : </p>

<pre><code>/usr/local/bin/
</code></pre>

<p>Pip installs modules over here : </p>

<pre><code>/usr/local/lib/python2.7/site-packages
</code></pre>

<p>Python is used from here : </p>

<pre><code>/usr/local/bin/python
</code></pre>

<p>Are these paths safe?</p>

<p>If you are on OS X, you should also have Python in <code>/usr/bin</code>:</p>

<pre><code>$ which -a python
/usr/local/bin/python
/usr/bin/python
</code></pre>

<p>If you are using <code>brew</code>, the first <code>python</code> should be a symlink:</p>

<pre><code>$ ls -hl $(which python)
lrwxr-xr-x  1 user  admin    34B Jun 23 16:53 /usr/local/bin/python -&gt; ../Cellar/python/2.7.11/bin/python
</code></pre>

<p>If you are not using <code>brew</code>, you will have to explain to us how you installed a second version of <code>python</code>.</p>

<p>You should also have at least two <code>site-packages</code>:</p>

<pre><code>$ find /usr -name 'site-packages'
/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages
/usr/local/lib/python2.7/site-packages
</code></pre>

<p>If you installed <code>python</code> using <code>brew</code>, you should also have <code>pip</code>:</p>

<pre><code>$ which pip
/usr/local/bin/pip
</code></pre>

<p>You should probably upgrade that to the latest <code>pip</code>:</p>

<pre><code>$ pip install --upgrade pip
</code></pre>

<p>It should be safe to install <code>python</code> packages using <code>/usr/local/bin/pip</code> because they will be installed in <code>/usr/local/lib/python2.7/site-packages</code>. The <code>/usr/local</code> path is specifically for <a href="http://www.pathname.com/fhs/pub/fhs-2.3.html#USRLOCALLOCALHIERARCHY" rel="nofollow">local software</a>. Also, <code>brew</code> installs its files to <code>/usr/local</code>, so if you are using <code>brew</code>, you are already installing files there.</p>

<p>I am not sure why some folks say not to install any packages globally. I have never seen a reference that explained why this was a bad idea. If multiple users need the same package, it makes more sense to install it globally.</p>

<p>When I first started using <code>virtualenv</code>, it did not always work the way I expected it too. I had a machine with multiple users that needed <code>requests</code>, and because of problems with <code>virtualenv</code>, I wound up installing it globally using <code>pip</code>.</p>

<p>Both <code>virtualenv</code> and <code>pip</code> have improved a lot since I first started using them and I can see how using them can prevent some problems. If you are developing new software that needs the latest version of a package, <code>virtualenv</code> allows you to install the package without affecting the rest of the system. However, I still do not see why it is a bad idea to install packages globally.</p>

python osx pip