如何使用 Hy 模块创建 Python 独立可执行文件?
How can I create a Python standalone executable using Hy modules?
给定一个条目文件 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 模块创建独立可执行文件的正确方法是什么?
Hy 未实现 PyInstaller 支持。我不知道是否需要对 PyInstaller、Hy 或两者进行更改。你总是可以先尝试 hy2py
ing 你的所有代码,但如果 (a) 你的代码仍然依赖于 Hy 和 (b) PyInstaller 在 Hy 上阻塞,即使用作普通的 Python 库,这可能不起作用.
给定一个条目文件 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 模块创建独立可执行文件的正确方法是什么?
Hy 未实现 PyInstaller 支持。我不知道是否需要对 PyInstaller、Hy 或两者进行更改。你总是可以先尝试 hy2py
ing 你的所有代码,但如果 (a) 你的代码仍然依赖于 Hy 和 (b) PyInstaller 在 Hy 上阻塞,即使用作普通的 Python 库,这可能不起作用.