简体   繁体   English

Mac OS 10.14.6 上的 LiClipse 8.1 无法运行 python 解释器(posix_spawn 失败)

[英]LiClipse 8.1 on Mac OS 10.14.6 cannot run python interpreter (posix_spawn failed)

maybe someone has seen this..也许有人看过这个..

fairly old Mac OS which might cause this, but mostly everything works OK:相当旧的 Mac OS 可能会导致这种情况,但大多数情况下一切正常:

  • Mac OS 10.14.6 (18G9323) Mac OS 10.14.6 (18G9323)
  • LiClipse 8.1.0.202110030926 com.brainwy.liclipse.rcp.product null LiClipse 8.1.0.202110030926 com.brainwy.liclipse.rcp.product null
  • Homebrew freshly updated (even though also complains OS is too old) and some packages reinstalled to make sure it's all cleared Homebrew 刚刚更新(尽管也抱怨操作系统太旧)并且重新安装了一些软件包以确保它全部被清除
$ pyenv versions
  system
  3.9.5
* 3.9.7 (set by /Users/aanisimov/.pyenv/version)

$ which python
/Users/aanisimov/.pyenv/shims/python

$ python --version
Python 3.9.7

LiClipse just cannot find it, tried all these buttons there (PATH, pip: what not) still the same error: LiClipse 只是找不到它,在那里尝试了所有这些按钮(PATH,pip:什么不是)仍然是同样的错误:

Errors getting info on discovered interpreter(s).
See error log for details.
  
  java.lang.RuntimeException: java.io.IOException: Cannot run program "/usr/bin/python": error=0, posix_spawn failed
  
  java.lang.RuntimeException: java.io.IOException: Cannot run program "/usr/bin/python2.7": error=0, posix_spawn failed
  
  java.lang.RuntimeException: java.io.IOException: Cannot run program "/usr/local/bin/python3": error=0, posix_spawn failed
  
  java.lang.RuntimeException: java.io.IOException: Cannot run program "/usr/local/bin/python3.9": error=0, posix_spawn failed

looks like it is trying to find it in most obvious locations, but unable to spawn the process to run it?看起来它正试图在最明显的位置找到它,但无法生成运行它的进程?

Python works OK via terminal and things like Sublime Text. Python 通过终端和 Sublime Text 之类的东西可以正常工作。

Thanks for any advice!感谢您的任何建议!

See attached screenshot as well!另请参阅随附的屏幕截图!

I had a problem very much like this, except with LiClipse version 8.2.0, running on macOS 12.4 Monterey, with Python interpreters installed by MacPorts.我遇到了非常类似的问题,除了在 macOS 12.4 Monterey 上运行的 LiClipse 版本 8.2.0,MacPorts 安装了 Python 解释器。 The symptoms were similar, except that LiClipse returned error code 316 instead of 0. What I wanted to know: how can I resolve this problem, so that LiClipse can add new interpreter entries in PyDev, and not display errors?症状相似,只是 LiClipse 返回错误代码 316 而不是 0。我想知道:如何解决此问题,以便 LiClipse 可以在 PyDev 中添加新的解释器条目,而不显示错误?

I came up with a workaround.我想出了一个解决方法。 I don't fully understand why it works, but I have some clues.我不完全理解它为什么起作用,但我有一些线索。

Workaround :解决方法

  1. Install a standard Eclipse app of the same vintage (Eclipse 2021-12, version 4.22, corresponds to LiClipse 8.2.0).安装相同年份的标准 Eclipse 应用程序(Eclipse 2021-12,版本 4.22,对应于 LiClipse 8.2.0)。

  2. Quit LiClipse.退出 LiClipse。

  3. Using a plain text editor, edit the file within LiClipse.app, LiClipse.app/Contents/Eclipse/LiClipse.ini .使用纯文本编辑器编辑 LiClipse.app 中的文件LiClipse.app/Contents/Eclipse/LiClipse.ini Change the lines in that file which read:更改该文件中的行:

     --launcher.defaultAction openFile -vmargs

    to read (of course replacing <myuserid> with your home directory name, and no line break in the very long line starting "/Users/"…):阅读(当然用您的主目录名称替换<myuserid> ,并且在以“/Users/”开头的很长的行中没有换行符......):

     --launcher.defaultAction openFile --launcher.appendVmargs -vm /Users/<myuserid>/.p2/pool/plugins/org.eclipse.justj.openjdk.hotspot.jre.full.macosx.x86_64_18.0.1.v20220515-1614/jre/lib/libjli.dylib -vmargs
  4. save LiClipse.ini.保存 LiClipse.ini。

  5. run LiClipse.app.运行 LiClipse.app。 It should now be able to add new interpreter entries in PyDev, with no errors.它现在应该能够在 PyDev 中添加新的解释器条目,并且没有错误。

  6. delete the Eclipse.app.删除 Eclipse.app。 (This should leave behind /Users//.p2/ undisturbed.) (这应该让 /Users//.p2/ 不受干扰。)

What it does :它的作用

I am not an expert on the internals of either LiClipse or Eclipse.我不是 LiClipse 或 Eclipse 内部的专家。 What I think is happening is that Eclipse supplies an OpenJDK for the app to run, it is different than the OpenJDK supplied by LiClipse, and it supports recent version of macOS better.我认为正在发生的是 Eclipse 为应用程序运行提供了一个 OpenJDK,它与 LiClipse 提供的 OpenJDK 不同,它更好地支持最新版本的 macOS。 Evidence of difference:差异的证据:

% /Applications/LiClipse.app/jre/Contents/Home/bin/java --version
openjdk 14.0.2 2020-07-14
OpenJDK Runtime Environment AdoptOpenJDK (build 14.0.2+12)
OpenJDK 64-Bit Server VM AdoptOpenJDK (build 14.0.2+12, mixed mode, sharing)

% /Users/<myuserid>/.p2/pool/plugins/org.eclipse.justj.openjdk.hotspot.jre.full.macosx.x86_64_18.0.1.v20220515-1614/jre/bin/java --version
openjdk 18.0.1 2022-04-19
OpenJDK Runtime Environment Temurin-18.0.1+10 (build 18.0.1+10)
OpenJDK 64-Bit Server VM Temurin-18.0.1+10 (build 18.0.1+10, mixed mode)

The LiClipse.ini file controls how the app starts up. LiClipse.ini文件控制应用程序的启动方式。 macOS runs a launcher program, and the launcher is guided by the contents of the ini file. macOS 运行一个启动器程序,启动器由 ini 文件的内容引导。 The inserted lines look to me like they tell the launcher to specify a different Java VM to use when running the main Eclipse/LiClipse application — to use the OpenJDK 18.0.1 supplied by Eclipse, saved in ~/.p2/ , instead of the OpenJDK 14.0.2 supplied by LiClipse;插入的行在我看来就像他们告诉启动器指定不同的 Java VM 在运行主 Eclipse/LiClipse 应用程序时使用 - 使用由 Eclipse 提供的 OpenJDK 18.0.1,而不是保存在~/.p2/中LiClipse 提供的 OpenJDK 14.0.2; and also to invoke a library libjli.dylib .并调用库libjli.dylib

Clues about the cause关于原因的线索

I don't know enough about the JDK to know what library libjli.dylib does.我对 JDK 知之甚少,不知道libjli.dylib库是做什么的。 There are clues in a StackOverflow answer, What is the Java libjli library for? StackOverflow 答案中有线索, Java libjli 库是干什么用的? , and in a blog post, Calling Java From C . ,并在博客文章中,从 C 调用 Java It looks like it helps interaction between the Java VM environment and the hosts's native language environment.看起来它有助于 Java VM 环境和主机的本地语言环境之间的交互。 The StackOverflow reply mentions, StackOverflow 的回复提到,

The libjli.so contains a launcher interface for preparing arguments passed in the command line and launching the virtual machine with them.… libjli.so 包含一个启动器接口,用于准备在命令行中传递的 arguments 并使用它们启动虚拟机。...

The error message in my case read,在我的案例中,错误消息为,

java.io.IOException: Cannot run program "/opt/local/Library/Frameworks/Python.framework/Versions/3.7/Resources/Python.app/Contents/MacOS/Python": error=316, posix_spawn failed java.io.IOException:无法运行程序“/opt/local/Library/Frameworks/Python.framework/Versions/3.7/Resources/Python.app/Contents/MacOS/Python”:错误=316,posix_spawn

I speculate that LiClipse was trying to call macOS to run the Python interpreter, but this attempt failed because the Java VM environment could not call the host's native environment successfully.我推测 LiClipse 试图调用 macOS 运行 Python 解释器,但这次尝试失败了,因为 Java VM 环境无法成功调用主机的原生环境。

The change to LiClipse.ini means that LiClipse uses a different OpenJDK, and invokes libjli differently.对 LiClipse.ini 的更改意味着 LiClipse 使用不同的 OpenJDK,并以不同的方式调用 libjli。 The combination of these differences seems to let the Java VM environment succeed in calling the host's native environment.这些差异的结合似乎让Java VM环境成功调用了宿主机的原生环境。

I speculate that a proper fix requires an update to LiClipse.我推测正确的修复需要更新 LiClipse。 I have opened ticket 239, 8.2.0 cannot run pythons and pips, "java.io.IOException: Cannot run program"... error=316, posix_spawn failed , to track it.我已经打开票239,8.2.0 无法运行 python 和点子,“java.io.IOException:无法运行程序”... error=316, posix_spawn failed ,来跟踪它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM