如何打包和导出您的所有项目?

发布于 2025-01-31 16:30:21 字数 256 浏览 3 评论 0原文

我是编程的初学者,并且已经完成了一个基于Python 3.8的项目,该项目使用了多个库,其中一些不包含在默认的Python环境中。

当我将带有.py代码的简单文件和图片(图标等)发送给我的朋友时,由于找不到库,代码未运行。同样,如果我用不同版本的Python运行它...

我想知道如何在单个文件中正确包装所有库和依赖项以导出?某人能够使用所需的库正确运行代码的结构是什么?

(在Visual Studio 2019上工作)

谢谢您的宝贵时间

I am a beginner at programming, and I have completed a project based on python 3.8 which uses several libraries, some not included in the default python environment.

When I send the simple file with the .py code and the pictures (icons etc) to my friend, the code does not run, as the libraries are not found. Same if I run it with a different version of python...

I was wondering how to properly pack all my libraries and dependencies in a single file to export? What is the structure to follow for someone to be able to run the code properly with the required libraries all included?

(working on visual studio 2019)

Thank you for your time

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

折戟 2025-02-07 16:30:21

指定Python脚本依赖项的常见做法是将$ pip Freeze>命令的输出重定向到名为infirmits.txt的文件。当然,请使用以下方式重定向操作员:$ pip冻结>需求.txt。然后,您的朋友可以$ pip install -r unignts.txt从您提供的存档中获取所需的库。请参阅$ pip帮助安装 pip文档有关更多详细信息。

编辑:
$ pip Freeze显然捕获的方式超出了必要的范围,您可以简单地编写需求文件中使用的库的名称,例如,

qrcode
pyperclip
pandas
numpy
<any other dependency>

每个库在单独的行上,并在平等符号后指定的版本如果需要。

The common practice for specifying your python script's dependencies is to redirect the output of the $ pip freeze command to a file named requirements.txt. That is of course done with the redirect operator as follows: $ pip freeze > requirements.txt. Your friend can then $ pip install -r requirements.txt from the archive you provided them to get the required libraries. Refer to $ pip help install and the pip documentation for more details.

EDIT:
$ pip freeze apparently captures way more than is necessary, you can simply write the names of libraries used in the requirements file by hand, e.g.

qrcode
pyperclip
pandas
numpy
<any other dependency>

with each one on seperate lines and with a version specified after an equal sign if needed.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文