如何从 PyCharm 导出 Python 程序 [英] How to export a Python program from PyCharm

查看:527
本文介绍了如何从 PyCharm 导出 Python 程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 PyCharm 中创建了一个 Python 项目.现在它完成了,我想在没有 PyCharm 的情况下使其可用(使其成为可执行文件无关紧要).它由不同的包和每个包内的相当多的文件组成.如何导出项目,以便我可以从一个文件中运行它,该文件将调用其余文件?

解决方案

如果你不想发布项目而只想自己使用:

  1. 在您的项目根目录中创建一个新的 __main__.py 并从那里启动您的程序(通过导入旧的 main.py 等)>

  2. 确保程序按预期运行:在根目录中运行 python __main__.py [arguments].

  3. 如果可行,请使用存档器压缩整个项目目录并像这样使用:

    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:

  1. Create a new __main__.py in your project root directory and start your program from there (by importing the old main.py etc.)

  2. Make sure the program runs as expected: Run python __main__.py [arguments] in the root directory.

  3. If this works, zip the whole project directory using an archiver and use like this:

    python myproject.zip [arguments]

这篇关于如何从 PyCharm 导出 Python 程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆