How to correctly uninstall numpy on MacOSX?
Solution 1
To solve this, I did the following: (note that it is not entirely clear to me which of these solved the problem, since I didn't test thoroughly).
1) Installed python at Python.org instead of Mac's stupid version
2) re-installed all of the modules like numpy
, scipy
, matplotlib
, sklearn
and ran this:hash -r python
according to this source: Symbol not found: __PyCodecInfo_GetIncrementalDecoder, because it doesn't make python use the cached versions of the modules.
3) Then, I realized that I had this issue: https://github.com/scipy/scipy/issues/5093. To solve it, I had to make sure I installed the scipy
module using python -m pip install scipy='0.15.0'
instead of just pip install scipy='0.15.0'
, because this solved the issue based on this source: Can't load Python modules installed via pip from site-packages directory.
So, in conclusion it turns out there really is a big different between what is installed by pip
, and what is imported when python
is executed from the terminal. So, to ensure that you are using the pip to install the modules into a particular python, you can use python -m pip install <package name>
.
Solution 2
I guess you are using MAC OS. I did a workaround to ignore the existing version of numpy (which MAC won't let you uninstall), and install an upgraded version.
Command :
pip install --upgrade --ignore-installed --install-option '--install-data=/usr/local' numpy
Worked fine for me.
Solution 3
I also getting this when I try to install pandas in MAC, but following command help me to get work around. Following command will ignore any previously installed version. Not sure it really fix issue behind though, but you can also have a try:
sudo pip install numpy --ignore-installed numpy
Solution 4
What works for my Mac OS 10.13.6 (High Sierra):
Just keep uninstalling numpy:
$sudo -H pip uninstall numpy DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7. Uninstalling numpy-1.16.2: Would remove: /Library/Python/2.7/site-packages/numpy-1.16.2.dist-info/* /Library/Python/2.7/site-packages/numpy/* ... Proceed (y/n)? y Successfully uninstalled numpy-1.16.2 $sudo -H pip uninstall numpy DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7. Uninstalling numpy-1.14.2: Would remove: /Library/Python/2.7/site-packages/numpy-1.14.2.dist-info/* ... Proceed (y/n)? y Successfully uninstalled numpy-1.14.2
(re-) Install numpy with option:
$ sudo -H pip install --ignore-installed numpy
DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7. Collecting numpy Downloading https://files.pythonhosted.org/packages/bc/90/3e71b5392bd81d8559917ee38857bb2e4b92c88e87211a68e339127b86f5/numpy-1.16.2-cp27-cp27m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl (13.9MB) 100% |████████████████████████████████| 13.9MB 921kB/s Installing collected packages: numpy Successfully installed numpy-1.16.2
Related videos on Youtube
makansij
I'm a PhD Student at University of Southern California.
Updated on March 04, 2020Comments
-
makansij about 4 years
I'm on a Mac, and I installed
numpy
andsklearn
in that order. Now, I'm faced with these errors that have already been mentioned on SO several times:sklearn "numpy.dtype has the wrong size, try recompiling" in both pycharm and terminal
ValueError: numpy.dtype has the wrong size, try recompiling
ImportError in importing from sklearn: cannot import name check_build
So, I try to remediate this error by uninstalling
numpy
, and reinstalling a previous version.1)
sudo pip install --upgrade numpy
..gives permission error...OSError: [Errno 1] Operation not permitted: '/tmp/pip-OVY0Vq-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy-1.8.0rc1-py2.7.egg-info'...
2) I tried
brew uninstall numpy
, butimport numpy
still works even after a shell restart.The only thing left I can think of is to manually delete all of the
numpy
files, which, on a Mac seeem to be found undersudo rm -rf /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy
....but even that gives me a permission error. what gives?
-
reticentroot over 7 yearsI probably would just remove the files manually and then to avoid errors and potentially damaging your operating system you should install your packages inside a virtual environment. E.g docs.python-guide.org/en/latest/dev/virtualenvs
-
makansij over 7 yearsbut, are those the correct files to remove?
-
makansij over 7 yearseven with
sudo
.....it won't let me remove them though!! Suggestions?? -
reticentroot over 7 yearsSudo chmod 777 the_path_to_file then try rm again.. that should give you read write access to the file
-
makansij over 7 yearsOkay, I try
sudo chmod 777 /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy
and I getchmod: Unable to change file mode on /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy: Operation not permitted
. What gives? -
reticentroot over 7 yearsLast thing I would try is to use the su command to become a super user. It is the highest privilege level, perhaps then you can rm or chmod.. if this is a mac you might also want to repair your disk permissions using disk utility. The newer operating systems removed that option but you can Google how to do that.
-
makansij over 7 yearsAm I the only one who thinks this shouldn't be that difficult!!!??
-
reticentroot over 7 yearsNo you're not the only one. I've never had this problem. I use pip or git exclusively (I don't use brew for python) and I always use a virtualenv. Installing on to your machines copy of python isn't good practice for a number of reasons. Instead of using terminal to remove it try and manually dragging and dropping the installation into the trash can. The os will ask for a password and that should be it.
-
reticentroot over 7 yearsJust as a thought your operating system is fighting you hard on this one you may want to rethink how you're going about doing this. It could be that case that if you did remove it, you might damage you'd os in some way. I would locate the file manually, inside whatever container/ version of python you are using.
-
Eric Leschinski over 6 yearsMac OSX has snatched the scepter of root from your fingers through bash. So you physically cannot delete those files no matter how much you want to. Only an operating system reinstall will nuke them, which only an Apple genius can do for you at cost of time and money. Enjoy your golden handcuffs lol.
-
tgunr over 6 yearsSounds like you have run up against System Intregrity Protection (SIP) which will prevent you from doing changes on certain files and folders. It can be disabled. See stackoverflow.com/questions/30768087/…
-
-
makansij over 7 years
pip upgrade
is the same aspip uninstall
and thenpip install
-
SinOfWrath over 7 yearswhich version of python are you running mac version or the brew one?,
-
makansij over 7 yearsHow do I find out?
-
SinOfWrath over 7 yearsby default it's the mac version even if you've installed python using brew, you should try installing numpy skearn using pip or pip3, also for python2.7 and python3 you will have to install libraries separately
-
SinOfWrath over 7 yearspython -c or python3 -c for checking path of python you're using
-
SinOfWrath over 7 yearsLet us continue this discussion in chat.
-
Tidhar Klein Orbach about 6 yearsadding -ignore-installed also solved the issue for me on centos. thanks!
-
Samuel Gómez over 5 yearsI had to use:
sudo pip install --upgrade --ignore-installed --install-option '--install-data=/usr/local' numpy
and it worked for me -
rj487 about 5 yearsYou save my day!