Mac OS X Cannot install packages with pip anymore
<p>I have completely screwed up my Python environment. My first big mistake was always installing packages using sudo and not using virtual environments. I'm not exactly sure what happened, but at some point I was not able to install certain packages anymore, possibly because of some dependency problems.</p>

<p>I decided to remove all the packages I installed with pip, unfortunately this did not help. Then I decided to uninstall pip itself and I actually tried to uninstall python myself.</p>

<p>Later on I found that the problem was probably caused because I had multiple python versions installed on my machine. </p>

<p>When I was trying to uninstall Python, I deleted the 2.7 framework version that was located in <code>/Library/Frameworks/Python.framework</code></p>

<p>If I use <code>/Library/Frameworks/Python.framework/Versions</code>, I only have a folder for 3.3.
In <code>/usr/local/bin</code> there is no python2.7, only python3.
In <code>/System/Library/Frameworks/Python.framework/Versions/</code> there is still a 2.7 folder.</p>

<p>If I call <code>which python</code> I get: <code>/usr/bin/python</code></p>

<p>This is where I am right now: The default python version is 2.7.5, I can use packages that I installed system wide using sudo, if I use the default python version. But some packages are not completely installed, e.g. scikit-learn is missing all modules and scipy is also missing some functionality. E.g. this is what I get when I import sklearn:</p>

<pre><code>In [2]: dir(sklearn)
Out[2]: 
['__SKLEARN_SETUP__',
 '__all__',
 '__builtins__',
 '__check_build',
 '__doc__',
 '__file__',
 '__name__',
 '__package__',
 '__path__',
 '__version__',
 'base',
 'clone',
 'exceptions',
 'externals',
 're',
 'setup_module',
 'sys',
 'utils',
 'warnings']
</code></pre>

<p>This is the path where Python looks for packages:</p>

<pre><code>['',
 '/usr/local/bin',
 '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python27.zip',
 '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7',
 '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin',
 '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac',
 '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages',
 '/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python',
 '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk',
 '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-old',
 '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload',
 '/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC',
 '/Library/Python/2.7/site-packages',
 '/Library/Python/2.7/site-packages/setuptools-28.3.0-py2.7.egg',
 '/Library/Python/2.7/site-packages/pip-8.1.2-py2.7.egg',
 '/Library/Python/2.7/site-packages/IPython/extensions',
 '/Users/bastiannaber/.ipython']
</code></pre>

<p>As I said before the <code>/System/Library/Frameworks/Python.framework/Versions/2.7</code> does not exist anymore on my system. <code>/Library/Python/2.7/site-packages</code> does still exist.</p>

<p>Can anybody tell me which python version I am using right now? And how can I fix these problems? Am I not supposed to have the default version in <code>/System/Library/Frameworks/Python.framework/Versions</code>. Can somebody please tell me how to fix my python environment?</p>

<p>The system Python is in <code>/usr/bin/</code>, not <code>/usr/local/bin/</code>, as you noted when you ran <code>which python</code>. Type <code>python --version</code> and it should tell you which version you're running.</p>

<p>In regards to your Python environment, I would recommend you ditch using the system environment, since you've accidentally removed Python. I'd suggest you install <a href="http://brew.sh" rel="nofollow">Homebrew</a>, then <code>brew install python</code>. That will also give you <code>pip</code> which will exist separately, as a fresh version, to your system python and pip.</p>

python osx python-2.7 pip