Reputation: 153
After I have upgraded to El Capitan, Python 2.7 is unable to install/ upgrade/ uninstall some packages, but meanwhile, it still works fine for some other packages.
Below (the end) is the error message I have got when trying to upgrade numpy. Same error also raises when I tried to uninstall it.
I have tried pip install --user or pip install --ignore-installed numpy, but neither works. Even if it says numpy has been successfully installed, the version remains unchanged and it does not really upgrade.
I know other solutions may be reinstall python using brew, but I want to avoid multiple versions of Python if possible. Any help would be appreciated.
----------- Error Message -----------
40:523: execution error: The directory '/Users/-/Library/Caches/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
DEPRECATION: Uninstalling a distutils installed project (numpy) has been deprecated and will be removed in a future version. This is due to the fact that uninstalling a distutils project will only partially uninstall the project. Exception: Traceback (most recent call last): File "/Library/Python/2.7/site-packages/pip/basecommand.py", line 211, in main status = self.run(options, args) File "/Library/Python/2.7/site-packages/pip/commands/install.py", line 311, in run root=options.root_path, File "/Library/Python/2.7/site-packages/pip/req/req_set.py", line 640, in install requirement.uninstall(auto_confirm=True) File "/Library/Python/2.7/site-packages/pip/req/req_install.py", line 716, in uninstall paths_to_remove.remove(auto_confirm) File "/Library/Python/2.7/site-packages/pip/req/req_uninstall.py", line 125, in remove renames(path, new_path) File "/Library/Python/2.7/site-packages/pip/utils/init.py", line 315, in renames shutil.move(old, new) File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 302, in move copy2(src, real_dst) File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 131, in copy2 copystat(src, dst) File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 103, in copystat os.chflags(dst, st.st_flags) OSError: [Errno 1] Operation not permitted: '/var/folders/m0/hzt3nk9d43n05bwm6zztqjkh0000gn/T/pip-HESb5m-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy-1.8.0rc1-py2.7.egg-info' (2)
Upvotes: 5
Views: 474
Reputation: 138
The python framework you are using
"/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7"
is the system python that comes with your mac os. You shouldn't pip install
packages as doing so may pollute your system python and potentially cause system problems. This is why other solutions suggest installing another python such as from brew brew install python@2
.
The issue you are running into after upgrading to el capitan is the System Integrity Protection built-in OS X El Capitan and later
You can disable this protection by following the steps described here:
After doing so, you will be able to install and upgrade packages using pip.
I do not recommend this, but it will work!
I suggest installing python using brew and then setup a virtual environment using pip
such that you can install python packages that won’t pollute the global python.
pip install virtualenv
pip install virtualenvwrapper
Upvotes: 0