![](/img/trans.png)
[英]How to create standalone executable when using subprocess in 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
使用 Hy 模塊創建獨立可執行文件的正確方法是什么?
Hy 未實現 PyInstaller 支持。 我不知道 PyInstaller、Hy 或兩者是否需要更改。 你總是可以先嘗試hy2py
ing 你的所有代碼,但如果 (a) 你的代碼仍然依賴於 Hy 並且 (b) 即使用作普通的 Python 庫,PyInstaller 也會在 Hy 上阻塞,這可能不起作用。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.