Home > Software design >  How to package and export all of your project?
How to package and export all of your project?

Time:05-27

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

CodePudding user response:

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.

  • Related