如何从 PyCharm 导出 Python 程序 [英] How to export a Python program from PyCharm
问题描述
我在 PyCharm 中创建了一个 Python 项目.现在它完成了,我想在没有 PyCharm 的情况下使其可用(使其成为可执行文件无关紧要).它由不同的包和每个包内的相当多的文件组成.如何导出项目,以便我可以从一个文件中运行它,该文件将调用其余文件?
如果你不想发布项目而只想自己使用:
在您的项目根目录中创建一个新的
__main__.py
并从那里启动您的程序(通过导入旧的main.py
等)>确保程序按预期运行:在根目录中运行
python __main__.py [arguments]
.如果可行,请使用存档器压缩整个项目目录并像这样使用:
python myproject.zip [参数]
I have a Python project created in PyCharm. Now that it's finished I want to make it available without PyCharm (making it an executable is not relevant). It consists of different packages and quite a few files inside each package. How can I export the project so I can run it from one file that will call the rest?
If you do not want to publish the project and just use it for yourself:
Create a new
__main__.py
in your project root directory and start your program from there (by importing the oldmain.py
etc.)Make sure the program runs as expected: Run
python __main__.py [arguments]
in the root directory.If this works, zip the whole project directory using an archiver and use like this:
python myproject.zip [arguments]
这篇关于如何从 PyCharm 导出 Python 程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!