2017-06-18 49 views
4

我正在查看Core ML Apple iOS框架。我已經讀過,安裝coremltools來創建自己的模型。我已經安裝python sudo python /Users/administrator/Downloads/get-pip.py安裝coremltools時出錯

按照文檔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$ 
+0

嘗試用'sudo'加前綴命令' – cdarke

+0

我試過但是同樣的錯誤。 – Stella

回答

15

您正試圖更改您的系統Python。這就是爲什麼它說[Errno 1] Operation not permitted。爲避免混淆系統庫,您需要創建單獨的Python虛擬環境。這是如何做到這一點:

  1. 升級PIP:

    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. 檢查庫已成功安裝:

    不應該有任何錯誤消息。

  7. 要禁用虛擬環境中運行:

    deactivate 
    

注:Never runpipsudo。如果你需要sudo,99%的機會你做錯了什麼。

+0

非常感謝您的詳細步驟。它一直工作。當我做了第6步,沒有錯誤。我真的不知道下一步該怎麼做,我的意思是使用'coremltools'如何創建自己的ML模型並用於Xcode項目。 – Stella

+0

他們有一個關於如何使用它的文檔,[例如sklearn](http://pythonhosted.org/coremltools/generated/coremltools.converters.sklearn.convert.html#coremltools.converters.sklearn.convert)。有[一些教程](https://www.bignerdranch.com/blog/machine-learning-in-ios-using-core-ml/)介紹如何將這些文件導入到iOS項目中。但是,如果您以前沒有機器學習的經驗,這將無濟於事。如果是這種情況,請嘗試從Coursera的一些scikit學習教程和課程開始。 –

+0

非常感謝。這真的有很大的幫助。我已經完成了機器學習課程......如果您發現任何其他教程使用Apple Coreml工具創建自己的模型,請繼續分享。非常感謝你。 – Stella

1

是他們的具體原因,你下載了.whl文件?

你雲嘗試從PyPI將直接安裝:

pip install -U coremltools 

這是如圖所示link,你已經發布的推薦方式。

注:我知道這不是一個非常複雜的答案,但我沒有足夠的聲望來評論。

+0

好的。我不知道文件不清楚。我剛剛下載了這個文件。無論如何,正如你所說的,我嘗試了'pip install -U coremltools',但觀察到完全相同的錯誤。 – Stella

-1

對於COREML:需要以下步驟:

  1. 檢查蟒蛇可用 - python --version
  2. 安裝從甲骨文網站的Mac 64位
  3. 然後sudo python -m ensurepip Java運行時。安裝PIP。如果你安裝python 3,PIP將被自動安裝了Python 3 :pip3 install -U pip setuptools

更新 -

  • 爲Mac安裝coremltools。

    brew install python3