python此应用无法在你的电脑上运行_在pyenv中使用py2app使用非系统Python构建的应用无法在其他计算机上运行...

My understanding was that as long as a non-Apple-default Python is employed to build, that the end-user need not install Python him/herself to execute a py2app-built app. In developing and testing the app in my own environment, I obviously have Python installed. Specifically, I built in a pyenv with with a python.org install, not Apple's own. Yet when I give the app to an end-user who doesn't have Python installed, she gets:

A Python runtime could not be located. You may need to install a

framework build of Python, or edit the PyRuntimeLocations array in

this application's Info.plist file.

The second line is concerning; if what it states is true, then a separate app instance would need to be built for every possible location of an end-user's install e.g /usr/bin, /Library/Frameworks etc.

UPDATE: Info.plist defines:

PythonExecutable

/Library/Frameworks/Python.framework/Versions/2.6/Resources/Python.app/Contents/MacOS/Python

Yet the end-user in question only has a system install in /usr/bin.

Does this mean that every end-user needs to have an externally-installed Python, and it must live in /Library/Frameworks/Python.framework/Versions/2.6/Resources/Python.app/Contents/MacOS/Python

What if they don't have a non-Apple Python? What if they have a non-Apple Python but it's not 2.6? How can this somewhat hardcoded dependency be avoided?

解决方案

py2app automatically defaults to --semi-standalone mode if it thinks you are using the system interpreter. Your interpreter from Python.org shouldn't count as a "system" interpreter, but you could see what py2app thinks using this command:

$ python -c "import py2app.build_app; print py2app.build_app.is_system()"

False

One issue to watch out for: After I installed a Python.org interpreter today, bash didn't update it's hash cache, causing strange incompatibilities when I launched python. I had to type hash -r python to reset the cache and make sure the correct version of python was getting used. (Another way to fix this is to log out and log in again.) I suppose it's possible that the same issue could have caused py2app to be confused about whether or not you were using the system python.

If that doesn't do the trick, then try installing your python interpreter to a weird location, like ~/mypython or something like that, just to make sure there's no way it can be confused for a system python.

As a last resort, I suppose you could just hack the py2app source code so that is_system() always returns False. Not sure if that would have any adverse consequences, though.

PS -- Here's a little tutorial on using py2app with a conda-packaged application:

https://github.com/stuarteberg/helloworld Not exactly relevant to your problem here, but you could compare it with your own setup and look for any conspicuous differences.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值