如何打包和导出您的所有项目?
我是编程的初学者,并且已经完成了一个基于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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
指定Python脚本依赖项的常见做法是将
$ pip Freeze>命令的输出重定向到名为
infirmits.txt
的文件。当然,请使用以下方式重定向操作员:$ pip冻结>需求.txt
。然后,您的朋友可以$ pip install -r unignts.txt
从您提供的存档中获取所需的库。请参阅$ pip帮助安装
和 pip文档有关更多详细信息。编辑:
$ pip Freeze
显然捕获的方式超出了必要的范围,您可以简单地编写需求文件中使用的库的名称,例如,每个库在单独的行上,并在平等符号后指定的版本如果需要。
The common practice for specifying your python script's dependencies is to redirect the output of the
$ pip freeze
command to a file namedrequirements.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.with each one on seperate lines and with a version specified after an equal sign if needed.