简体   繁体   English

有没有办法使用 kivy 在虚拟环境中制作 .exe?

[英]Is there a way to make a .exe on a virtual environment using kivy?

After creating the virtual environment I put my python file in the folder the open my command prompt at that file location and do: pyinstaller helloworld.py创建虚拟环境后,我将我的 python 文件放在文件夹中,在该文件位置打开我的命令提示符并执行:pyinstaller helloworld.py

This successfully creates the file.这成功地创建了文件。 When I open the folder “dist” then navigate to helloworld.exe I'm the next folder, I run it and it closes.当我打开文件夹“dist”然后导航到 helloworld.exe 我是下一个文件夹时,我运行它并关闭它。 I added a input to the helloworld.py as recommended but when I update everything and run helloworld.exe, it only stays open long enough for an input then closes afterwards.我按照建议向 helloworld.py 添加了一个输入,但是当我更新所有内容并运行 helloworld.exe 时,它​​只保持打开足够长的时间以供输入,然后关闭。 There are no errors.没有错误。 I know the kivy is aborting but I can't figure out why.我知道 kivy 正在中止,但我不知道为什么。 Can anyone help me figure out why?谁能帮我弄清楚为什么?

 import kivy from kivy.app import App from from kivy.uix.label import Label class MyApp(App): def build(self): return Label(text='Hello world') if __name__ == '__main__': MyApp().run()

You may need to activate your virtual environment (ven) first.您可能需要先激活您的虚拟环境 (ven)。

`Open cmd
cd into program_folder/venv/bin
"activate.bat" 

cd back to folder with .py

pyinstaller .py`

Anytime you want to use your venv in a cmd session, you will need to do this.任何时候你想在 cmd 会话中使用你的 venv,你都需要这样做。

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

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