[英]py2app Can't find Python Framework
I'm trying to use py2app to create a simple Python application on a Mac.我正在尝试使用 py2app 在 Mac 上创建一个简单的 Python 应用程序。 I'm just trying to get py2app to work so right now my Python program looks like this:
我只是想让 py2app 正常工作,所以现在我的 Python 程序如下所示:
#!/usr/bin/env python
x = "hello"
print(x)
I'm running these commands in the terminal as per the py2app documentation:我按照 py2app 文档在终端中运行这些命令:
py2applet --make-setup MyApplication.py
python setup.py py2app -A
After I run these I get this error message.运行这些后,我收到此错误消息。
MyApplication[57520:1908985] A Python runtime not could be located. You may need to install a framework build of Python, or edit the PyRuntimeLocations array in this application's Info.plist file.
Looking in the Info.plist , these are the PyRuntimeLocations:查看Info.plist ,这些是 PyRuntimeLocations:
@executable_path/../Frameworks/libpython3.7.dylib
/Users/me/opt/anaconda3/lib/libpython3.7.dylib
I have Python installed and I also tried installing it through homebrew (because I saw that as a solution for someone else) but it's not working for me.我安装了 Python,我也尝试通过自制软件安装它(因为我认为这是其他人的解决方案),但它对我不起作用。 I've also tried editting the plist but that also did not get me anywhere.
我也试过编辑 plist 但这也没有让我到任何地方。
Any ideas how I could get this working?我有什么想法可以让这个工作吗?
Thank you谢谢
I noticed that you have anaconda installed thanks to this由于这个,我注意到你安装了 anaconda
/Users/me/opt/anaconda3/lib/libpython3.7.dylib
/Users/me/opt/anaconda3/lib/libpython3.7.dylib
I had the same problem and I've just solve it.我有同样的问题,我刚刚解决了它。
I noticed that in my terminal this appeared (base) tag in terminal我注意到在我的终端中出现了终端中的(基本)标签
And it gave me the same error that A Python runtime not could be located.它给了我同样的错误,即无法定位 Python 运行时。 First I tried to do all my project in a virtual environment running python 3.9 and when I got to the
首先,我尝试在运行 python 3.9 的虚拟环境中完成我的所有项目,当我到达
$ python setup.py py2app -A
It gave me the same error, but noticed that my terminal was looking like this (env)(base) tags它给了我同样的错误,但注意到我的终端看起来像这样(env)(base) 标签
As it were using two virtual environments, so in your terminal first run $ your_environment deactivate
in case you are using a virtual environment and then you run $ conda deactivate
which will get you out of the base environment conda get you in by default.由于它使用两个虚拟环境,所以在终端第一次运行
$ your_environment deactivate
的情况下,您使用的是虚拟的环境,然后运行$ conda deactivate
,这将让你出基地环境的康达默认情况下,得到你进去。
And finally you repeat the process of最后你重复这个过程
$ python setup.py py2app -A
What happens is that if you're in the conda (base) venv, it will search the Framework in the opt directory without much success, but actually I will also recommend you to use a virtual environment for your project since you can use whatever python version you want and it's like a whole version packed in a directory with all the libraries you need so your app would be more independent with that.发生的情况是,如果你在 conda (base) venv 中,它会在 opt 目录中搜索框架,但没有太大成功,但实际上我也建议你为你的项目使用虚拟环境,因为你可以使用任何 python你想要的版本,就像一个完整的版本,打包在一个包含你需要的所有库的目录中,这样你的应用程序就会更加独立。 If you've never used it don't worry it's pretty straight forward I'd just learned it myself two days ago to solve the exact same problem.
如果您从未使用过它,请不要担心它非常简单,我两天前刚刚学会了它来解决完全相同的问题。
Hope I helped :)希望我有所帮助:)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.