安装coremltools时出错

时间:2017-06-18 08:13:32

标签: python ios swift coreml

我正在寻找Core ML Apple iOS框架。我已经读过安装coremltools来创建自己的模型。我已经安装了python sudo python /Users/administrator/Downloads/get-pip.py

根据文档coreml installation我已经下载了coremltool文件。

然后尝试安装coremltools

https://pypi.python.org/pypi/coremltools

当我在我的mac上安装coremltools时,我收到以下错误。请建议我解决这个错误。这样我就可以在coremltools

上工作了
MyMacbook:~ administrator$ pip install -U /Users/administrator/Downloads/coremltools-0.3.0-py2.7-none-any.whl 
Processing ./Downloads/coremltools-0.3.0-py2.7-none-any.whl
Requirement already up-to-date: numpy>=1.6.2 in /Library/Python/2.7/site-packages (from coremltools==0.3.0)
Collecting protobuf>=3.1.0 (from coremltools==0.3.0)
Requirement already up-to-date: six>=1.9 in /Library/Python/2.7/site-packages/six-1.10.0-py2.7.egg (from protobuf>=3.1.0->coremltools==0.3.0)
Collecting setuptools (from protobuf>=3.1.0->coremltools==0.3.0)
  Using cached setuptools-36.0.1-py2.py3-none-any.whl
Installing collected packages: setuptools, protobuf, coremltools
  Found existing installation: setuptools 18.5
    Uninstalling setuptools-18.5:
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 342, in run
    prefix=options.prefix_path,
  File "/Library/Python/2.7/site-packages/pip/req/req_set.py", line 778, in install
    requirement.uninstall(auto_confirm=True)
  File "/Library/Python/2.7/site-packages/pip/req/req_install.py", line 754, 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 299, in move
    copytree(src, real_dst, symlinks=True)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 208, in copytree
    raise Error, errors
Error: [('/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/__init__.py', '/var/folders/h1/z0gcmgkx6b9_l2_zpyzvl7tm0000gn/T/pip-DFHVSK-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/__init__.py', "[Errno 1] Operation not permitted: '/var/folders/h1/z0gcmgkx6b9_l2_zpyzvl7tm0000gn/T/pip-DFHVSK-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/__init__.py'"), ('/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/__init__.pyc', '/var/folders/h1/z0gcmgkx6b9_l2_zpyzvl7tm0000gn/T/pip-DFHVSK-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/__init__.pyc', "[Errno 1] Operation not permitted: '/var/folders/h1/z0gcmgkx6b9_l2_zpyzvl7tm0000gn/T/pip-DFHVSK-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/__init__.pyc'"), ('/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/markers.py', '/var/folders/h1/z0gcmgkx6b9_l2_zpyzvl7tm0000gn/T/pip-DFHVSK-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/markers.py', "[Errno 1] Operation not permitted: '/var/folders/h1/z0gcmgkx6b9_l2_zpyzvl7tm0000gn/T/pip-DFHVSK-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/markers.py'"), ('/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/markers.pyc', '/var/folders/h1/z0gcmgkx6b9_l2_zpyzvl7tm0000gn/T/pip-DFHVSK-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/markers.pyc', "[Errno 1] Operation not permitted: '/var/folders/h1/z0gcmgkx6b9_l2_zpyzvl7tm0000gn/T/pip-DFHVSK-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/markers.pyc'"), ('/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib', '/var/folders/h1/z0gcmgkx6b9_l2_zpyzvl7tm0000gn/T/pip-DFHVSK-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib', "[Errno 1] Operation not permitted: '/var/folders/h1/z0gcmgkx6b9_l2_zpyzvl7tm0000gn/T/pip-DFHVSK-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib'")]
MyMacbook:~ administrator$ 

4 个答案:

答案 0 :(得分:18)

您正在尝试更改系统Python。这就是为什么它说[Errno 1] Operation not permitted。为避免弄乱系统库,您需要创建单独的Python虚拟环境。这是怎么做的:

  1. 升级点数:

    pip install --upgrade pip
    
  2. 安装virtual environment

    pip install –U virtualenv
    
  3. 创建新的虚拟环境:

    cd ~
    virtualenv coreml
    

    这会创建文件夹~/coreml/以及Python的本地副本,pip以及工作所需的所有其他内容。

  4. 激活虚拟环境:

    source coreml/bin/activate
    

    现在您在终端(coreml)中看到了您的用户名。

  5. 在新创建的虚拟环境中:

    pip install -U coremltools
    
  6. 检查库是否已成功安装:

    python
    import coremltools
    

    不应该有任何错误消息。

  7. 停用虚拟环境:

    deactivate
    
  8. 注意:Never run pipsudo。如果你需要sudo,99%你有可能做错了。

答案 1 :(得分:1)

他们是一个特定的原因,你下载了.whl文件吗?

您尝试直接从PyPI安装:

pip install -U coremltools

这是推荐的方式,如您已发布的link所示。

注意:我知道这不是一个非常复杂的答案,但我没有足够的声誉来评论。

答案 2 :(得分:0)

pip install git+https://github.com/apple/coremltools

我将其安装在可正常运行的Windows上:)

答案 3 :(得分:-1)

对于COREML:需要执行以下步骤:

  1. 检查python是否可用 - python --version
  2. 从Oracle网站为Mac 64位安装Java运行时
  3. 然后sudo python -m ensurepip。安装PIP。
  4. 安装适用于Mac的coremltools - pip3 install -U pip setuptools
  5. 更新:Python 3 如果安装python 3,将自动安装pip。

    brew install python3