0

给定一个入口文件 main.py,如下所示:

#-*- coding: utf-8 -*-
# -*- mode: python -*-

import hy
import os.path
import hymodule

datas=[(os.path.dirname(hy.__file__), 'hy')]

hymodule.hello_world()

给定一个 Hy 文件 hymodule.hy:

(defn hello-world []
  (print "hello world!"))

如果我使用 pyinstaller 创建一个独立文件:

pyinstaller main.py --onefile 

并执行 main.exe 我得到这个错误:

 $ ./dist/main.exe
Traceback (most recent call last):
  File "main.py", line 6, in <module>
    import hymodule
ModuleNotFoundError: No module named 'hymodule'
[10852] Failed to execute script main
  • 如果我使用 python(不使用 pyinstaller)执行 main.py,一切正常。
  • 如果我将 hymodule 更改为 Python 模块并使用 pyinstaller,一切正常

使用 Hy 模块创建独立可执行文件的正确方法是什么?

4

1 回答 1

1

Hy 没有实现 PyInstaller 支持。我不知道是否需要对 PyInstaller、Hy 或两者都进行更改。您总是可以hy2py先尝试所有代码,但如果 (a) 您的代码仍然依赖于 Hy 并且 (b) PyInstaller 阻塞 Hy,即使用作普通 Python 库,这可能不起作用。

于 2019-12-24T14:52:07.990 回答