[英]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.我想创建一个名为“躲避球”的应用程序,我有我的主脚本(使用 pygame)和我的 setup.py 脚本。 I need an image named ball.bmp that I need as well.
我还需要一个名为 ball.bmp 的图像。
Inside my setup.py script I have the following code: from setuptools import setup在我的 setup.py 脚本中,我有以下代码: 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).如果有帮助,我在 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.
我知道 El Capitan 与任何 Apple 更新一样,将拥有可能会破坏此类内容的新软件和功能。
QUESTION题
How do I fix this error and then allow py2app to make a fully functionable app?如何修复此错误,然后允许 py2app 制作一个功能齐全的应用程序?
After I upgraded my operating system to OS X El Capitan (10.11.2), I got similar error when packaging my app using py2app:将操作系统升级到 OS X El Capitan (10.11.2) 后,使用 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;我做了一些研究并找到了一个解决方案:1)禁用 SIP; 2) remove restricted file flag on Python.framework.
2) 删除 Python.framework 上的受限文件标志。 It worked for me.
它对我有用。
Restart your Mac.重新启动您的 Mac。
Before OS X starts up, hold down Command+R and keep it held down until you see an Apple icon and a progress bar.在 OS X 启动之前,按住 Command+R 并保持按住直到看到 Apple 图标和进度条。 Release.
释放。 This boots you into Recovery.
这将引导您进入恢复。
From the Utilities menu, select Terminal.从实用程序菜单中,选择终端。
At the prompt type the following:在提示符下键入以下内容:
csrutil status csrutil disable reboot
You can re-enable SIP by following the above steps, but using:您可以按照上述步骤重新启用 SIP,但使用:
csrutil enable
References:参考:
sudo chflags -R norestricted /System/Library/Frameworks/Python.framework
As it's mentioned in https://forums.developer.apple.com/thread/6987正如在https://forums.developer.apple.com/thread/6987 中提到的
I had the same problem.我有同样的问题。 Instead of running
而不是跑步
python setup.py py2app
I tried我试过
python3 setup.py py2app
and it worked just fine.它工作得很好。 Hope this helps.
希望这可以帮助。
Don't use the system provided py2app.不要使用系统提供的 py2app。 Running this fixed the issue for me:
运行它为我解决了这个问题:
pip install --user --ignore-installed py2app
(I'm usually wary of things that require me to disable System Integrity Protection) (我通常对需要我禁用系统完整性保护的事情持谨慎态度)
This doesn't happen if you build and install your own py2app rather than depending on the OS-bundled one.如果您构建和安装自己的py2app而不是依赖操作系统捆绑的py2app,则不会发生这种情况。
Inside your virtualenv, install Mercurial (if needed), then:在您的 virtualenv 中,安装 Mercurial(如果需要),然后:
pip install hg+https://bitbucket.org/ronaldoussoren/py2app/
py2app
should then work without issue. py2app
应该可以正常工作。
-U
flag!-U
标志安装! Since all of you will have installed py2app already, start by uninstalling it.既然你们都已经安装了 py2app,首先卸载它。
pip3 uninstall py2app
After this point, it's crucial that you reinstall it using the -U
flag!在这一点之后,使用
-U
标志重新安装它是至关重要的! 📦 📦
pip3 install -U py2app
py2applet --make-setup YourApp.py
python3 setup.py py2app -A
Look in your dist/
folder, there should now be a runnable application.查看您的
dist/
文件夹,现在应该有一个可运行的应用程序。
Then you can rebuild it using python3 setup.py py2app
然后你可以使用
python3 setup.py py2app
重建它
Verified on OS X Catalina, Mojave, Big Sur在 OS X Catalina、Mojave、Big Sur 上验证
I had this same error on my Mac, version Sierra 10.12.我在我的 Mac 版本 Sierra 10.12 上遇到了同样的错误。 My inspiration came from @Nicholas Riley's answer.
我的灵感来自@Nicholas Riley 的回答。
The context of my issue:我的问题的背景:
$ py2applet --make-setup MyApplication.py
$ py2applet --make-setup MyApplication.py
My solution:我的解决方案:
activate the virtualenv激活虚拟环境
Spievats-MacBook-Pro:EasyGuiTest user$ source bin/activate
install py2app in the virtualenv在 virtualenv 中安装 py2app
(EasyGuiTest) Spievats-MacBook-Pro:EasyGuiTest brady$ pip install py2app
run py2app again再次运行 py2app
(EasyGuiTest) Spievats-MacBook-Pro:EasyGuiTest brady$ python setup.py py2app -A
This worked perfectly!这工作得很好! I hope it helps someone else.
我希望它可以帮助别人。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.