Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
553 views
in Technique[技术] by (71.8m points)

python - Py2app: Operation not permitted

I want to create an application called 'dodgeball' and I have my main script (which uses pygame), and my setup.py script. I need an image named ball.bmp that I need as well.

Inside my setup.py script I have the following code: from setuptools import setup

APP = ['dodgeball.py']
DATA_FILES = ["ball.bmp"]
OPTIONS = {'argv_emulation': True}

setup(
    app=APP,
    data_files=DATA_FILES,
    options={'py2app': OPTIONS},
    setup_requires=['py2app'],
)

Whenever I try to make the application using the following stuff in Terminal:

python setup.py py2app

everything works up to

*** creating application bundle: dodgeball ***

then it returns an error:

error: [Errno 1] Operation not permitted: '/Users/**********/Desktop/Dodgeball/dist/dodgeball.app/Contents/MacOS/dodgeball'

If it helps, I'm on Mac OS X El Capitan (10.11). I'm aware that El Capitan, like any Apple update, will have new software and features that may break stuff like this.

QUESTION

How do I fix this error and then allow py2app to make a fully functionable app?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

After I upgraded my operating system to OS X El Capitan (10.11.2), I got similar error when packaging my app using py2app:

*** creating application bundle: MyApp ***
error: [Errno 1] Operation not permitted: '/Users/jake/work/my-app/dist/MyApp.app/Contents/MacOS/MyApp'

I did some research and found a solution: 1) disable SIP; 2) remove restricted file flag on Python.framework. It worked for me.

Disable SIP

  1. Restart your Mac.

  2. Before OS X starts up, hold down Command+R and keep it held down until you see an Apple icon and a progress bar. Release. This boots you into Recovery.

  3. From the Utilities menu, select Terminal.

  4. At the prompt type the following:

    csrutil status
    csrutil disable
    reboot
    

You can re-enable SIP by following the above steps, but using:

csrutil enable

References:

Remove Restricted File Flag

sudo chflags -R norestricted /System/Library/Frameworks/Python.framework

As it's mentioned in https://forums.developer.apple.com/thread/6987


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...