[PYTHON] Check! Troubleshooting when installing PyObjc on Mac

Hello, this is @dz_ this and Ohira Kazumi.

Prologue-Introduction

I've stumbled upon some of the PyObjc installations during the process, so I'll keep a reminder.

#Introduce PyObjc (update)
$ pip install -U pyobjc

Work environment

trouble shooting

tool'xcodebuild' requires Xcode and error

error contents

The error is that xcodebuild is requesting Xcode itself, not the command line tools.

$ sudo pip install -U pyobjc

Collecting pyobjc
  Using cached pyobjc-3.1.1.tar.gz
Collecting py2app>=0.10 (from pyobjc)
  Using cached py2app-0.10.tar.gz
Collecting pyobjc-core==3.1.1 (from pyobjc)
  Using cached pyobjc-core-3.1.1.tar.gz
    Complete output from command python setup.py egg_info:
    running egg_info
    creating pip-egg-info/pyobjc_core.egg-info
    writing include/pyobjc-compat.h to pip-egg-info/pyobjc_core.egg-info/include/pyobjc-compat.h
    writing include/pyobjc-api.h to pip-egg-info/pyobjc_core.egg-info/include/pyobjc-api.h
    writing pip-egg-info/pyobjc_core.egg-info/PKG-INFO
    writing namespace_packages to pip-egg-info/pyobjc_core.egg-info/namespace_packages.txt
    writing top-level names to pip-egg-info/pyobjc_core.egg-info/top_level.txt
    writing dependency_links to pip-egg-info/pyobjc_core.egg-info/dependency_links.txt
    writing manifest file 'pip-egg-info/pyobjc_core.egg-info/SOURCES.txt'
    warning: manifest_maker: standard file '-c' not found
    
    xcode-select: error: tool 'xcodebuild' requires Xcode, but active developer directory '/Library/Developer/CommandLineTools' is a command line tools instance
    Traceback (most recent call last):

...<Abbreviation>...
    
    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/lc/x_6095kd7xz1x7cjkp7vnmsm0000gp/T/pip-build-Aq79NE/pyobjc-core/

Coping

Please install Xcode from the Mac App Store.

Error with You have not agreed to the Xcode license agreements

error contents

If you get the following error, you haven't licensed xcode.

$ sudo pip install -U pyobjc

Password:

Collecting pyobjc
  Downloading pyobjc-3.1.1.tar.gz
Collecting py2app>=0.10 (from pyobjc)
  Downloading py2app-0.10.tar.gz (1.7MB)
    100% |████████████████████████████████| 1.7MB 694kB/s 
Collecting pyobjc-core==3.1.1 (from pyobjc)
  Downloading pyobjc-core-3.1.1.tar.gz (2.2MB)
    100% |████████████████████████████████| 2.2MB 564kB/s 
    Complete output from command python setup.py egg_info:
    running egg_info
    creating pip-egg-info/pyobjc_core.egg-info
    writing include/pyobjc-compat.h to pip-egg-info/pyobjc_core.egg-info/include/pyobjc-compat.h
    writing include/pyobjc-api.h to pip-egg-info/pyobjc_core.egg-info/include/pyobjc-api.h
    writing pip-egg-info/pyobjc_core.egg-info/PKG-INFO
    writing namespace_packages to pip-egg-info/pyobjc_core.egg-info/namespace_packages.txt
    writing top-level names to pip-egg-info/pyobjc_core.egg-info/top_level.txt
    writing dependency_links to pip-egg-info/pyobjc_core.egg-info/dependency_links.txt
    writing manifest file 'pip-egg-info/pyobjc_core.egg-info/SOURCES.txt'
    warning: manifest_maker: standard file '-c' not found
    
    
    You have not agreed to the Xcode license agreements, please run 'xcodebuild -license' (for user-level acceptance) or 'sudo xcodebuild -license' (for system-wide acceptance) from within a Terminal window to review and agree to the Xcode license agreements.

...<Abbreviation>...

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /private/tmp/pip-build-qqJvg7/pyobjc-core/

Coping

Use xcodebuild to accept the license.

#Accept the Xcode license
$ sudo xcodebuild -license

Password:


You have not agreed to the Xcode license agreements. You must agree to both license agreements below in order to use Xcode.

Hit the Enter key to view the license agreements at '/Applications/Xcode.app/Contents/Resources/English.lproj/License.rtf'

If you press the ʻEnter key here, the license agreement document will be displayed, so use the space` key to read to the bottom.

...<Abbreviation>...

By typing 'agree' you are agreeing to the terms of the software license agreements. Type 'print' to print them or anything else to cancel, [agree, print, cancel]

When you see this, type ʻagree` to complete the license acceptance.

You can view the license agreements in Xcode's About Box, or at /Applications/Xcode.app/Contents/Resources/English.lproj/License.rtf

Error with pyobjc-framework-AVKit

error contents

$ sudo pip install -U pyobjc

Password:

Collecting pyobjc
  Downloading pyobjc-3.1.1.tar.gz
Collecting py2app>=0.10 (from pyobjc)
  Downloading py2app-0.10.tar.gz (1.7MB)
    100% |████████████████████████████████| 1.7MB 562kB/s 
Collecting pyobjc-core==3.1.1 (from pyobjc)
  Downloading pyobjc-core-3.1.1.tar.gz (2.2MB)
    100% |████████████████████████████████| 2.2MB 595kB/s 
Collecting pyobjc_framework-AVKit==3.1.1 (from pyobjc)
  Downloading pyobjc-framework-AVKit-3.1.1.tar.gz
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/private/tmp/pip-build-8BPKlF/pyobjc-framework-AVKit/setup.py", line 35, in <module>
        if fn.startswith('_AVKit')
      File "pyobjc_setup.py", line 496, in setup
        **k
      File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/core.py", line 111, in setup
        _setup_distribution = dist = klass(attrs)
      File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/setuptools/dist.py", line 239, in __init__
        self.fetch_build_eggs(attrs.pop('setup_requires'))
      File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/setuptools/dist.py", line 263, in fetch_build_eggs
        parse_requirements(requires), installer=self.fetch_build_egg
      File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 580, in resolve
        raise VersionConflict(dist,req) # XXX put more info here
    pkg_resources.VersionConflict: (pyobjc-core 2.5.1 (/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC), Requirement.parse('pyobjc-core>=3.1.1'))
    
    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /private/tmp/pip-build-8BPKlF/pyobjc-framework-AVKit/

Cause analysis

        raise VersionConflict(dist,req) # XXX put more info here
    pkg_resources.VersionConflict: (pyobjc-core 2.5.1 (/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC), Requirement.parse('pyobjc-core>=3.1.1'))

Apparently, the version of pyobjc-core has 2.5.1 installed, but 3.1.1 is required.

Coping

#View a list of packages installed with pip
$ pip list

...<Abbreviation>...

pyobjc-core (2.5.1)

...<Abbreviation>...

I tried to update explicitly with sudo pip install -U pyobjc-core, but it was [Errno 1] Operation not permitted and could not be uploaded.

Therefore, I explicitly installed python other than the system default to deal with it. For version control of each language, ʻanyenv` is recommended. (Reference: Use phpenv with Check! Anyenv (Mac OS X))

#python version check
$ python --version
Python 2.7.10

#Check the version of pip
$ pip --version
pip 9.0.1 from /Library/Python/2.7/site-packages (python 2.7)

#Install pyenv using anyenv
$ anyenv install pyenv

#Reload the shell
$ exec $SHELL -l

# python 3.5.Install 2
$ pyenv install 2.7.12

#Check the installed version
$ pyenv versions
* system (set by /Users/user/.anyenv/envs/pyenv/version)
  2.7.12

# python 2.7.Enable 12
$ pyenv global 2.7.12

#pip update
$ pip install --upgrade pip

When I installed pyobjc-core in this state, it completed normally.

# pyobjc-core installation
$ pip install -U pyobjc-core
Collecting pyobjc-core
  Using cached pyobjc-core-3.1.1.tar.gz
Installing collected packages: pyobjc-core
  Running setup.py install for pyobjc-core ... done
Successfully installed pyobjc-core-3.1.1

There is no problem if you install (update) pyobjc itself instead of pyobjc-core here.

Epilogue-Conclusion

Actually, it is a troubleshooting when trying to put pyBluez on Mac, but even if I clear the installation of PyObjc, the essential pyBluez has the following problem I couldn't install it ... It ended in the middle of my mind. (By the way, the pyBluez issue has been fixed and will appear in the release soon.)

Recommended Posts

Check! Troubleshooting when installing PyObjc on Mac
Notes on installing dlib on mac
Notes on installing pipenv on Mac
Support when installing pillow on python3.9
Error and solution when installing python3 with homebrew on mac (catalina 10.15)
Error resolution when installing numba on macOS
Error, warning when using TensorFlow on Mac
python on mac
Check types_map when using mimetypes on AWS Lambda (Python)
Instructions for installing CUDA 7.5 on Mac (El Capitan) + Homebrew
Installing Python 3 on Mac and checking basic operation Part 1
Minimum memo when using Python on Mac (pyenv edition)
Minimum notes when using Python on Mac (Homebrew edition)
Install Tensorflow on Mac
Install pyenv on mac
Stumbled when installing PyOCR
Install Ansible on Mac
Install Python 3 on Mac
Notes on installing PycURL
Installing pandas on python2.6
Run OpenMVG on Mac
Precautions when installing fbprophet
Install Python 3.4 on Mac
Installing pyenv on ubuntu 16.04
Install Caffe on Mac
Install mecab on mac
Check capacity on Linux
Try deepdream on Mac
Precautions and solutions when installing Ubuntu on NVIDIA GeForce PCs
(Note) Points to be addicted to when installing Scilab on ArchLinux