解决 mac安装或者更新第三方包安装不上的问题 mac OSX pip OSError: [Errno 1] Operation not permitted

(1) 写在前面

在安装机器学习python包时,提示Macbook里面的Python库有点旧,就用pip更新一下。

 

$ sudo pip install pandas

$ pip install --upgrade numpy

在安装过程中出现了如下错误:

OSError: [Errno 1] Operation not permitted: '/var/folders/bm/dccwv2v97y75hdshqnh1bbpr0000gn/T/pip-_dyADZ-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy-1.8.0rc1-py2.7.egg-info'

(2) 具体错误报告如下:

 

 
  1. localhost:Applications a6$ sudo pip install pandas

  2. The directory '/Users/a6/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.

  3. The directory '/Users/a6/Library/Caches/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.

  4. Collecting pandas

  5. Downloading pandas-0.21.0-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 (16.7MB)

  6. 100% |████████████████████████████████| 16.7MB 48kB/s

  7. Requirement already satisfied: pytz>=2011k in /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python (from pandas)

  8. Requirement already satisfied: python-dateutil in /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python (from pandas)

  9. Collecting numpy>=1.9.0 (from pandas)

  10. Downloading numpy-1.13.3-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 (4.6MB)

  11. 100% |████████████████████████████████| 4.6MB 6.4kB/s

  12. Installing collected packages: numpy, pandas

  13. Found existing installation: numpy 1.8.0rc1

  14. 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.

  15. Uninstalling numpy-1.8.0rc1:

  16. Exception:

  17. Traceback (most recent call last):

  18. File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/basecommand.py", line 215, in main

  19. status = self.run(options, args)

  20. File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/commands/install.py", line 342, in run

  21. prefix=options.prefix_path,

  22. File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/req/req_set.py", line 778, in install

  23. requirement.uninstall(auto_confirm=True)

  24. File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/req/req_install.py", line 754, in uninstall

  25. paths_to_remove.remove(auto_confirm)

  26. File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/req/req_uninstall.py", line 115, in remove

  27. renames(path, new_path)

  28. File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/utils/__init__.py", line 267, in renames

  29. shutil.move(old, new)

  30. File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 302, in move

  31. copy2(src, real_dst)

  32. File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 131, in copy2

  33. copystat(src, dst)

  34. File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 103, in copystat

  35. os.chflags(dst, st.st_flags)

  36. OSError: [Errno 1] Operation not permitted: '/tmp/pip-jPsGEm-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy-1.8.0rc1-py2.7.egg-info'

  37.  
 
  1. localhost:Applications a6$ pip install -U numpy

  2. Collecting numpy

  3. Using cached numpy-1.13.3-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

  4. Installing collected packages: numpy

  5. Found existing installation: numpy 1.8.0rc1

  6. 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.

  7. Uninstalling numpy-1.8.0rc1:

  8. Exception:

  9. Traceback (most recent call last):

  10. File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/basecommand.py", line 215, in main

  11. status = self.run(options, args)

  12. File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/commands/install.py", line 342, in run

  13. prefix=options.prefix_path,

  14. File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/req/req_set.py", line 778, in install

  15. requirement.uninstall(auto_confirm=True)

  16. File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/req/req_install.py", line 754, in uninstall

  17. paths_to_remove.remove(auto_confirm)

  18. File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/req/req_uninstall.py", line 115, in remove

  19. renames(path, new_path)

  20. File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/utils/__init__.py", line 267, in renames

  21. shutil.move(old, new)

  22. File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 302, in move

  23. copy2(src, real_dst)

  24. File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 131, in copy2

  25. copystat(src, dst)

  26. File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 103, in copystat

  27. os.chflags(dst, st.st_flags)

  28. OSError: [Errno 1] Operation not permitted: '/var/folders/bm/dccwv2v97y75hdshqnh1bbpr0000gn/T/pip-_dyADZ-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy-1.8.0rc1-py2.7.egg-info'

  29.  
 
  1. localhost:Applications a6$ sudo pip install -U numpy

  2. The directory '/Users/a6/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.

  3. The directory '/Users/a6/Library/Caches/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.

  4. Collecting numpy

  5. Downloading numpy-1.13.3-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 (4.6MB)

  6. 100% |████████████████████████████████| 4.6MB 198kB/s

  7. Installing collected packages: numpy

  8. Found existing installation: numpy 1.8.0rc1

  9. 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.

  10. Uninstalling numpy-1.8.0rc1:

  11. Exception:

  12. Traceback (most recent call last):

  13. File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/basecommand.py", line 215, in main

  14. status = self.run(options, args)

  15. File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/commands/install.py", line 342, in run

  16. prefix=options.prefix_path,

  17. File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/req/req_set.py", line 778, in install

  18. requirement.uninstall(auto_confirm=True)

  19. File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/req/req_install.py", line 754, in uninstall

  20. paths_to_remove.remove(auto_confirm)

  21. File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/req/req_uninstall.py", line 115, in remove

  22. renames(path, new_path)

  23. File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/utils/__init__.py", line 267, in renames

  24. shutil.move(old, new)

  25. File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 302, in move

  26. copy2(src, real_dst)

  27. File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 131, in copy2

  28. copystat(src, dst)

  29. File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 103, in copystat

  30. os.chflags(dst, st.st_flags)

  31. OSError: [Errno 1] Operation not permitted: '/tmp/pip-QissHG-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy-1.8.0rc1-py2.7.egg-info'

 

(3) 解决办法

1) 一番百度,Google后找到这个解决方案:

$ pip install --upgrade pip
$ sudo pip install numpy --upgrade --ignore-installed
$ sudo pip install scipy --upgrade --ignore-installed
$ sudo pip install scikit-learn --upgrade --ignore-installed
$ sudo pip install scipy --upgrade --ignore-installed

2) 具体代码如下:

 

 
  1. localhost:Applications a6$ sudo pip install scipy --upgrade --ignore-installed

  2. The directory '/Users/a6/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.

  3. The directory '/Users/a6/Library/Caches/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.

  4. Collecting scipy

  5. Downloading scipy-1.0.0-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 (16.8MB)

  6. 100% |████████████████████████████████| 16.8MB 41kB/s

  7. Collecting numpy>=1.8.2 (from scipy)

  8. Downloading numpy-1.13.3-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 (4.6MB)

  9. 100% |████████████████████████████████| 4.6MB 89kB/s

  10. Installing collected packages: numpy, scipy

  11. Successfully installed numpy-1.13.3 scipy-1.0.0

  12. localhost:Applications a6$ pip install --upgrade pip

  13. Requirement already up-to-date: pip in /Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg

  14. localhost:Applications a6$ sudo pip install -U numpy

  15. The directory '/Users/a6/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.

  16. The directory '/Users/a6/Library/Caches/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.

  17. Requirement already up-to-date: numpy in /Library/Python/2.7/site-packages

  18.  
 
  1. localhost:Applications a6$ sudo pip install pandas

  2. The directory '/Users/a6/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.

  3. The directory '/Users/a6/Library/Caches/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.

  4. Collecting pandas

  5. Downloading pandas-0.21.0-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 (16.7MB)

  6. 100% |████████████████████████████████| 16.7MB 54kB/s

  7. Requirement already satisfied: pytz>=2011k in /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python (from pandas)

  8. Requirement already satisfied: python-dateutil in /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python (from pandas)

  9. Requirement already satisfied: numpy>=1.9.0 in /Library/Python/2.7/site-packages (from pandas)

  10. Installing collected packages: pandas

  11. Successfully installed pandas-0.21.0

  12. localhost:Applications a6$

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值