Error pyobjc requires macos to build

PyObjC supports Python 3.6 or later and does not support Python 2.

Supported versions¶

PyObjC supports Python 3.6 or later and does not support Python 2.

PyObjC does not support other python implementation such as PyPy and Jython.

PyObjC is regularly tested on macOS 10.14 and should work on macOS
10.9 or later for the i386 and x86_64 architectures.

PyObjC only supports macOS and does not support other platform (iOS, Linux, …)

Installation¶

PyObjC is distributed as a collection of Python packages and can be installed
using pip. Manual installation is also supported, but is a lot more work and is
therefore more of a power-user feature.

Installation using pip¶

Installing or upgrading PyObjC using pip is easy:

For most users this will install PyObjC using wheel binary
archives, which means you don’t have to have a compiler on your machine.

Some use cases require installation of all framework bindings, not just those that are
relevant for the current system. In PyObjC 8 you can install framework bindings using the
allbindings* extra:

$ pip3 install -U 'pyobjc[allbindings]'

This requires using binary wheels, otherwise this can attempt to install bindings that
require a newer SDK than available on the current machine.

Note

Pip will install PyObjC 5 for users of Python 2.7, but only when using
pip 9 or later.

Manual installation¶

Manual installation is slightly involved, but still pretty easy.

  • First download the source code packages from the cheeseshop, you
    need at least pyobjc-core and
    pyobjc-framework-Cocoa.
    You do not need pyobjc, that’s a helper package that is only
    used to pull in the other packages when installing using pip.

  • Extract the archives

  • Install every packages using the standard recipe for Python package
    installation:

    $ python setup.py install
    

    Due to package dependencies you need to install the packages in a
    particular order:

    • pyobjc-core

    • pyobjc-framework-Cocoa

    • pyobjc-framework-Quartz

    • all other packages (in arbitrary order)

Requirements for building from source¶

PyObjC contains extensions and is distributed as source code. You therefore
need a compiler to install PyObjC. The easiest way to get a compiler is do
download Xcode from the Mac App Store.

Depending on the Python release you may need to install the Command Line
Tools for Xcode. To install the Command Line Tools first install Xcode from
the Mac App Store. The next action depends on the OSX release you are using.

If you use OSX 10.8 or earlier, open Xcode and then open
the Xcode preferences. The downloads tab contains an option “components” and
that list contains an option to install the “Command Line Tools”.

If you use OSX 10.9 or later, open a Terminal window and run xcode-select --install.

Advanced installation options¶

Distributing binaries to other macOS releases¶

It is possible to create self-contained application bundles for PyObjC based
application using py2app. You do need to take some care when
you want to ship these applications to machines running a different
version of macOS than the one you used for the build

  • Later versions of macOS should work fine

  • Earlier version of macOS work fine, but you do need to ensure that
    Python itself is build with MACOSX_DEPLOYMENT_TARGET set to the earliest
    version of macOS you want to support. PyObC, and other extension packages,
    should automatically pick up the deployment target from the Python build.

    Note

    PyObjC contains code that explicitly weak-links to a number of APIs that
    are not available on all macOS releases.

    You might still end up with an application that won’t run on earlier
    releases when you use another extension module that (accidentally) hard links
    to an API that is not available in the earlier release.

Closed

Installation of pyobjc-Core makes watchdog unusable on non MacOS hardware #618

Issue Opened

Jperkelens Opened Issue On Jan 28th 2020, 2:21

Jperkelens

Collecting pyobjc-core==6.1

  Downloading https://artifactory.us-east-1.bamgrid.net/api/pypi/dataengineering-pypi/packages/packages/3a/80/0cdb2130b86a984e4765beb93135aa9c2120fd64be1a27e1c7cb31c719bc/pyobjc-core-6.1.tar.gz (791 kB)

    ERROR: Command errored out with exit status 1:

     command: /databricks/python3/bin/python3.7 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-09k75p2e/pyobjc-core/setup.py'"'"'; __file__='"'"'/tmp/pip-install-09k75p2e/pyobjc-core/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'rn'"'"', '"'"'n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' --no-user-cfg egg_info --egg-base /tmp/pip-install-09k75p2e/pyobjc-core/pip-egg-info

         cwd: /tmp/pip-install-09k75p2e/pyobjc-core/

    Complete output (2 lines):

    running egg_info

    error: PyObjC requires macOS to build

    ----------------------------------------

ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

script returned exit code 1 

Comment

BoboTiG commented on 3 years ago

BoboTiG

Unfortunately, I cannot reproduce yet.
Could you tell me what returns:

import os
import sys
from distutils.util import get_platform

print(sys.platform)
print(os.getenv("_PYTHON_HOST_PLATFORM"))
print(get_platform())
print(os.name)
print(os.uname()) 

And what is your OS and OS version?

Comment

BoboTiG commented on 3 years ago

BoboTiG

Could you try to install the version from that branch: https://github.com/gorakhargosh/watchdog/tree/fix-use-sys-platform?

Jperkelens

The output of the commands is:

Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> import sys
>>> from distutils.util import get_platform
>>>
>>> print(sys.platform)
linux2
>>> print(os.getenv("_PYTHON_HOST_PLATFORM"))
None
>>> print(get_platform())
linux-x86_64
>>> print(os.name)
posix
>>> print(os.uname())
('Linux', '4969f8496763', '4.9.184-linuxkit', '#1 SMP Tue Jul 2 22:58:16 UTC 2019', 'x86_64')
>>> 

The contents of the /etc/os-release file are:

# cat /etc/os-release
NAME="Ubuntu"
VERSION="16.04.4 LTS (Xenial Xerus)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 16.04.4 LTS"
VERSION_ID="16.04"
HOME_URL="http://www.ubuntu.com/"
SUPPORT_URL="http://help.ubuntu.com/"
BUG_REPORT_URL="http://bugs.launchpad.net/ubuntu/"
VERSION_CODENAME=xenial
UBUNTU_CODENAME=xenial 

Jperkelens

installing from the branch you mentioned seems to have worked:

# git clone https://github.com/gorakhargosh/watchdog.git
Cloning into 'watchdog'...
remote: Enumerating objects: 35, done.
remote: Counting objects: 100% (35/35), done.
remote: Compressing objects: 100% (28/28), done.
remote: Total 6532 (delta 16), reused 16 (delta 7), pack-reused 6497
Receiving objects: 100% (6532/6532), 1.49 MiB | 1.47 MiB/s, done.
Resolving deltas: 100% (4296/4296), done.
Checking connectivity... done.
# cd watchdog
# git co fix-use-sys-platform
git: 'co' is not a git command. See 'git --help'.

Did you mean one of these?
        commit
        clone
        log
# git checkout fix-use-sys-platform
Branch fix-use-sys-platform set up to track remote branch fix-use-sys-platform from origin.
Switched to a new branch 'fix-use-sys-platform'
# pip install .
Processing /proj/watchdog
Requirement already satisfied: pathtools>=0.1.1 in /databricks/python3/lib/python3.7/site-packages (from watchdog==0.10.1) (0.1.2)
Building wheels for collected packages: watchdog
  Building wheel for watchdog (setup.py) ... done
  Created wheel for watchdog: filename=watchdog-0.10.1-cp37-none-any.whl size=73440 sha256=33fccd6797d042e4cae828d49264ba86ae17b36ccbb9c704740b72c8088995e7
  Stored in directory: /tmp/pip-ephem-wheel-cache-xdb4ajfs/wheels/81/44/af/0aa0091701a91f0b9c476c731521faee5ea94f30fdede49318
Successfully built watchdog
Installing collected packages: watchdog
  Found existing installation: watchdog 0.9.0
    Uninstalling watchdog-0.9.0:
      Successfully uninstalled watchdog-0.9.0
Successfully installed watchdog-0.10.1 

Comment

BoboTiG commented on 3 years ago

BoboTiG

Great news! Even if I do not understand how it happened :D

Bhargavrpatel

~@BoboTiG We are seeing this issue right not as well, so wondering when 0.10.1 will be released.~
Edit: Looks like this version will be released tomorrow.

Comment

Robvdl commented on 3 years ago

Robvdl

I’ve got something similar to this but I am not on a Mac.

I am working on a project right now that still uses Python 3.4 (yes I know, beyond my control) and ever since the release of watchdog 0.10.0 on January 27 our Travis CI jobs have started failing.

That is because for some weird reason it’s started thinking Travis CI is a Mac and it tries to install PyLibObjC which then blows up because this file is never goingo exist on Linux:

FileNotFoundError: [Errno 2] No such file or directory: ‘/System/Library/CoreServices/SystemVersion.plist’

I believe however it shouldn’t be installing PyLibObjC at all on Linux, only on Mac.

For now I am pinning watchdog to the previous version until this is resolved. It does not fail on Python 3.6 as we run CI on various Python versions, only 3.4 is actually doing this.

Bhargavrpatel

@robvdl Looks like 0.10.1 will be released tomorrow. So you can probably unpin your dependencies after that.

Addendum: An alternative would be to pn the pyobjc requirements in your Pipfile specificing the version marker. This is similar to Constraints files.

# This is being installed specific for drawin and a patch around the incorrect
# requirements declared in `watchdog`. This is resolved in watchdog==0.10.1
# which is currently not released.
pyobjc-core = {version="*", sys_platform = "== 'darwin'"}
pyobjc-framework-cocoa = {version="*", sys_platform = "== 'darwin'"}
pyobjc-framework-fsevents = {version="*", sys_platform = "== 'darwin'"} 

Comment

Robvdl commented on 3 years ago

Robvdl

Ah good, I was just re-reading over the previous comments and realised it was the same issue and a fix was already made thanks. I’ll probably just wait it out, no point adding a pin for 1 day, it’s weekend anyway.

Comment

BoboTiG commented on 3 years ago

BoboTiG

The release 0.10.1 is out :)

Comment

Robvdl commented on 3 years ago

Robvdl

Hate to be the bearer of bad news but unfortunately this issue still exists when installing watchdog==0.10.1 on Travis CI using Trusty/python 3.4 (though 3.6 doesn’t do it).

Collecting pyobjc-framework-Cocoa>=4.2.2 (from watchdog==0.10.1)
  Downloading https://files.pythonhosted.org/packages/ff/86/acf828be23970164440c9a3591ae4ace703f707a348f544941272ace52ff/pyobjc-framework-Cocoa-5.3.tar.gz (3.8MB)
    ERROR: Complete output from command python setup.py egg_info:
    ERROR: Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-wheel-c8o6gsxs/pyobjc-framework-Cocoa/setup.py", line 24, in <module>
        extra_link_args=['-framework', 'CoreFoundation']),
      File "/tmp/pip-wheel-c8o6gsxs/pyobjc-framework-Cocoa/pyobjc_setup.py", line 392, in Extension
        os_level = get_os_level()
      File "/tmp/pip-wheel-c8o6gsxs/pyobjc-framework-Cocoa/pyobjc_setup.py", line 206, in get_os_level
        pl = plistlib.readPlist('/System/Library/CoreServices/SystemVersion.plist')
      File "/opt/python/3.4.6/lib/python3.4/plistlib.py", line 162, in readPlist
        with _maybe_open(pathOrFile, 'rb') as fp:
      File "/opt/python/3.4.6/lib/python3.4/contextlib.py", line 59, in __enter__
        return next(self.gen)
      File "/opt/python/3.4.6/lib/python3.4/plistlib.py", line 120, in _maybe_open
        with open(pathOrFile, mode) as fp:
    FileNotFoundError: [Errno 2] No such file or directory: '/System/Library/CoreServices/SystemVersion.plist' 

I still am finding that installing watchdog==0.10.1 on Travis (trusty) and python 3.4 is thinking it’s a Mac and trying to install PyObjC.

I can understand you may want to drop support for Trusty, if that is the case I can pin the old version of watchdog temporarily until we can finalise moving our client to Bionic, it’s in progress anyway just slower than I would hope.

The weird thing is in a Trusty vagrant VM it won’t do it, tried rebuilding the Vagrant VM and it’s absolutely fine. So it seems to be isolated to Travis CI and Python 3.4?

Somewacko

Another issue related to this is that because the system platform is determined at install-time, this makes pinning dependencies (e.g with pip freeze or pip-tools) across platforms difficult.

For example if I’m on macOS and do:

pip install watchdog ...
pip freeze > requirements.txt 

requirements.txt would have pyobjc-core, which would break installs for non-macOS users.

Our solution was to add ; sys_platform == 'darwin' to the requirements.txt manually:

pyobjc-core; sys_platform == 'darwin'                # via watchdog
pyobjc-framework-cocoa; sys_platform == 'darwin'     # via watchdog
pyobjc-framework-fsevents; sys_platform == 'darwin'  # via watchdog 

(perhaps this is pyobjc’s fault though, I feel like it should fail at run-time, not install-time)

Comment

BoboTiG commented on 3 years ago

BoboTiG

Also, would #623 fix this?

Not at all. As PyObjC will always required.

Comment

BoboTiG commented on 3 years ago

BoboTiG

This is already what we do (since the beginning), see: https://github.com/gorakhargosh/watchdog/blob/8f7e051a06205c8c22345bf1fd8ed4a8f19d26bf/setup.cfg#L4-L5

Somewacko

Yeah thinking through this more I don’t see many solutions that watchdog could implement.

I think pyobjc shouldn’t fail installs on non-macOS platforms. I opened an issue there if anyone wants to follow/contribute: https://bitbucket.org/ronaldoussoren/pyobjc/issues/291/install-fails-on-non-macos-platforms

Comment

Robvdl commented on 3 years ago

Robvdl

Also @zo7 in my particular case I’m pretty sure it could be failing to parse this on python 3.4 because of the version of setuptools and pip in use:

pyobjc-framework-Cocoa >= 4.2.2 ; sys_platform == "darwin" 
pyobjc-framework-FSEvents >= 4.2.2 ; sys_platform == "darwin" 

Python 3.4 will only take upto a particular version of setuptools and pip and it’s quite possible that those versions are not parsing this syntax yet?

I am just thinking because this is working fine on Python 3.6, we have a CI job with a build matrix and only 3.4 is actually failing here but 3.6 is passing.

There for I was suggesting an option could be to say you no longer support python 3.4 for the 0.10.x version, it’s no longer in support anyway and many projects have done this already.

People still using Python 3.4 are likely already transitioning of it anyway, we can just pin 0.9.0 right now and it’s fine, I wouldn’t worry if Python 3.4 support was actually dropped officially in watchdog.

Recommend Projects

  • React photo

    React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo

    Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo

    Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo

    TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo

    Django

    The Web framework for perfectionists with deadlines.

  • Laravel photo

    Laravel

    A PHP framework for web artisans

  • D3 photo

    D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Visualization

    Some thing interesting about visualization, use data art

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo

    Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo

    Microsoft

    Open source projects and samples from Microsoft.

  • Google photo

    Google

    Google ❤️ Open Source for everyone.

  • Alibaba photo

    Alibaba

    Alibaba Open Source for everyone

  • D3 photo

    D3

    Data-Driven Documents codes.

  • Tencent photo

    Tencent

    China tencent open source team.

View community ranking In the Top 1% of largest communities on Reddit

Cant install pyobjc, pyobjc-core, pyautogui on a fresh install of MacOS Sierra.

I reinstalled MacOS on my MacBook Pro and decided to install Python for learning. I installed python3 threw brew. I then tried to install pyobjc and other packages as noted in Automate the Boring Stuff, but kept getting an «Egg error.» I’ve gone back and installed Xcode and and the command line tools, but I still get the same error.

I pasted the full error text below. Thanks for helping.

USER-MacBook-Pro:~ USER$ sudo pip3 install pyobjc-core
    Password:
    The directory '/Users/USER/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/USER/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 pyobjc-core
      Downloading pyobjc-core-3.1.1.tar.gz (2.2MB)
        100% |████████████████████████████████| 2.2MB 543kB/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 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 namespace_packages to pip-egg-info/pyobjc_core.egg-info/namespace_packages.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):
          File "<string>", line 1, in <module>
          File "/private/tmp/pip-build-xfg7bonu/pyobjc-core/setup.py", line 696, in <module>
            **parse_package_metadata()
          File "/usr/local/Cellar/python3/3.5.2_3/Frameworks/Python.framework/Versions/3.5/lib/python3.5/distutils/core.py", line 148, in setup
            dist.run_commands()
          File "/usr/local/Cellar/python3/3.5.2_3/Frameworks/Python.framework/Versions/3.5/lib/python3.5/distutils/dist.py", line 955, in run_commands
            self.run_command(cmd)
          File "/usr/local/Cellar/python3/3.5.2_3/Frameworks/Python.framework/Versions/3.5/lib/python3.5/distutils/dist.py", line 974, in run_command
            cmd_obj.run()
          File "/private/tmp/pip-build-xfg7bonu/pyobjc-core/setup.py", line 371, in run
            egg_info.egg_info.run(self)
          File "/usr/local/lib/python3.5/site-packages/setuptools/command/egg_info.py", line 195, in run
            self.find_sources()
          File "/usr/local/lib/python3.5/site-packages/setuptools/command/egg_info.py", line 222, in find_sources
            mm.run()
          File "/usr/local/lib/python3.5/site-packages/setuptools/command/egg_info.py", line 306, in run
            self.add_defaults()
          File "/usr/local/lib/python3.5/site-packages/setuptools/command/egg_info.py", line 335, in add_defaults
            sdist.add_defaults(self)
          File "/usr/local/lib/python3.5/site-packages/setuptools/command/sdist.py", line 160, in add_defaults
            build_ext = self.get_finalized_command('build_ext')
          File "/usr/local/Cellar/python3/3.5.2_3/Frameworks/Python.framework/Versions/3.5/lib/python3.5/distutils/cmd.py", line 299, in get_finalized_command
            cmd_obj.ensure_finalized()
          File "/usr/local/Cellar/python3/3.5.2_3/Frameworks/Python.framework/Versions/3.5/lib/python3.5/distutils/cmd.py", line 107, in ensure_finalized
            self.finalize_options()
          File "/private/tmp/pip-build-xfg7bonu/pyobjc-core/setup.py", line 525, in finalize_options
            universal_newlines=True).strip()
          File "/usr/local/Cellar/python3/3.5.2_3/Frameworks/Python.framework/Versions/3.5/lib/python3.5/subprocess.py", line 626, in check_output
            **kwargs).stdout
          File "/usr/local/Cellar/python3/3.5.2_3/Frameworks/Python.framework/Versions/3.5/lib/python3.5/subprocess.py", line 708, in run
            output=stdout, stderr=stderr)
        subprocess.CalledProcessError: Command '['/usr/bin/xcodebuild', '-version', '-sdk', 'macosx', 'Path']' returned non-zero exit status 1
        
        ----------------------------------------
    Command "python setup.py egg_info" failed with error code 1 in /private/tmp/pip-build-xfg7bonu/pyobjc-core/

Понравилась статья? Поделить с друзьями:
  • Error protocol pxf does not exist
  • Error please select a valid python interpreter как исправить pycharm
  • Error please reinstall ivcam
  • Error pkgproblemresolver resolve generated breaks this may be caused by held packages kali linux
  • Error pkgbuild does not exist