给定一个入口文件 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 模块创建独立可执行文件的正确方法是什么?