【问题标题】:Have trouble uninstall scipy on osx在 osx 上卸载 scipy 时遇到问题
【发布时间】:2023-04-08 00:43:02
【问题描述】:

我在 2.7 和 3.4 的多版本 python 中遇到了这个特定的问题。 python2.7 是苹果自己安装的,我自己安装了 3.4,效果很好。
当我使用pip安装sklearn系列(scikit-learn numpy scipy)时,由于这个pip绑定到python3.4所以python2.7无法使用它,我的项目这次需要2.7。
我不会卸载 3.4。

sh-3.2# python
Python 2.7.10 (default, Oct 23 2015, 18:05:06) 
[GCC 4.2.1 Compatible Apple LLVM 7.0.0 (clang-700.0.59.5)] on darwin
Type "help", "copyright", "credits" or "license" for more information.


这意味着我的默认 python 版本是 2.7

我的问题是当我使用pip install 并仅通过 pip 卸载时,python3.4 中的附加功能可以正常工作。
为了将 numpy 和 scipy 安装到 python2.7,我下载了这些包并找到了那些 setup.py 并使用 sudo python setup.py install 运行它们。

numpy 看起来不错,但 scipy 有这个麻烦,因为

error: Command "/usr/local/bin/gfortran -Wall -g -ffixed-form -fno-second-underscore -arch x86_64 -fPIC -I/Library/Python/2.7/site-packages/numpy-1.12.0.dev0_d69c147-py2.7-macosx-10.11-intel.egg/numpy/core/include -c -c scipy/integrate/mach/d1mach.f -o build/temp.macosx-10.11-intel-2.7/scipy/integrate/mach/d1mach.o" failed with exit status 1

当我没有 gfortran 时,我在 scipy 下运行这个“sudo python setup.py install”(当然我失败了,发现我需要一个)。在得到 gfortran 之后,我陷入了这个恼人的错误。

我的计划是先用 pip 卸载 scipy,但我无法面对这个

$ pip2.7 uninstall scipy
DEPRECATION: Uninstalling a distutils installed project (scipy) 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.
Uninstalling scipy-0.13.0b1:



/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/scipy-0.13.0b1-py2.7.egg-info
Proceed (y/n)? y
Exception:
Traceback (most recent call last):
  File "/Library/Python/2.7/site-packages/pip/basecommand.py", line 215, in main
    status = self.run(options, args)
  File "/Library/Python/2.7/site-packages/pip/commands/uninstall.py", line 76, in run
    requirement_set.uninstall(auto_confirm=options.yes)
  File "/Library/Python/2.7/site-packages/pip/req/req_set.py", line 336, in uninstall
    req.uninstall(auto_confirm=auto_confirm)
  File "/Library/Python/2.7/site-packages/pip/req/req_install.py", line 742, in uninstall
    paths_to_remove.remove(auto_confirm)
  File "/Library/Python/2.7/site-packages/pip/req/req_uninstall.py", line 115, in remove
    renames(path, new_path)
  File "/Library/Python/2.7/site-packages/pip/utils/__init__.py", line 267, 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/8k/7_gm8zxx0zlg0nx4r5dg4rz00000gn/T/pip-hA6VUE-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/scipy-0.13.0b1-py2.7.egg-info'

我很沮丧,但仍在努力。并寻求帮助。

我不是说英语的人。很抱歉我的英语不好。



更新:只是解决了这个问题,我修复了所有其他问题,例如 pandas 或 sklearn

sudo pip2.7 install numpy --upgrade
The directory '/Users/ink/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.
The directory '/Users/ink/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.
Collecting numpy
  Downloading numpy-1.11.0-cp27-cp27m-<br>macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl (3.9MB)
    100% |████████████████████████████████| 3.9MB 275kB/s 
Installing collected packages: numpy
  Found existing installation: numpy 1.8.0rc1
    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.
    Uninstalling numpy-1.8.0rc1:
Exception:
Traceback (most recent call last):
  File "/Library/Python/2.7/site-packages/pip/basecommand.py", line 215, in main
    status = self.run(options, args)
  File "/Library/Python/2.7/site-packages/pip/commands/install.py", line 317, in run
    prefix=options.prefix_path,
  File "/Library/Python/2.7/site-packages/pip/req/req_set.py", line 736, in install
    requirement.uninstall(auto_confirm=True)
  File "/Library/Python/2.7/site-packages/pip/req/req_install.py", line 742, in uninstall
    paths_to_remove.remove(auto_confirm)
  File "/Library/Python/2.7/site-packages/pip/req/req_uninstall.py", line 115, in remove
    renames(path, new_path)
  File "/Library/Python/2.7/site-packages/pip/utils/__init__.py", line 267, 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: '/tmp/pip-gJ8Ao6-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy-1.8.0rc1-py2.7.egg-info'

【问题讨论】:

    标签: python macos python-2.7 numpy


    【解决方案1】:

    安装 brew

    http://brew.sh/
    

    然后按照这个食谱..

    https://penandpants.com/2013/04/04/install-scientific-python-on-mac-os-x/

    ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go)"
    export PATH=/usr/local/bin:/usr/local/share/python:$PATH
    
    brew install python
    brew tap homebrew/science
    
    brew install gfortran
    brew install numpy --with-openblas
    brew install scipy --with-openblas
    brew install matplotlib
    brew install zeromq
    
    pip install ipython
    pip install pandas
    pip install sklearn
    

    【讨论】:

    • 我认为除了 numpy 之外,我已经与所有其他人一起管理。有什么想法吗?
    【解决方案2】:
    aptitude purge python-numpy
    

    试试这个

    【讨论】:

    • 我为什么需要能力?
    【解决方案3】:

    有一个类似的问题,通过重新安装 python https://www.python.org/downloads/ 得到解决

    【讨论】:

      猜你喜欢
      • 2012-03-31
      • 1970-01-01
      • 2021-09-24
      • 2012-04-06
      • 2012-09-19
      • 2018-03-12
      • 1970-01-01
      • 1970-01-01
      • 2018-05-27
      相关资源
      最近更新 更多