What if the end-user didn't have the required library?

Whatever your project is, you could try making it into a python package that the end-user would install. The way this works is

In the root directory of your package you would include a setup.py. You could include in this file a list of requirements/dependencies (the install_requires key) that would be installed along with your package when the end-user installs it.

The end user could then use pip to install your package eg

pip install YourPackage

and all dependencies listed in setup.py would be installed first.

Additionally, as @Devesh Kumar Singh pointed out in his comment, you could also include a requirements.txt file. The user could then install using this file with

pip install -r requirements.txt YourPackage

See this guide for building a python package, setuptools documentation


To show other users, what libraries are needed for your project, you have multiple options. All options are some kind of files, that say which libraries are needed for this project.

Files that I am aware of

  • requirements.txt: very simple
  • setup.py: Used when you publish your project on sides like pypi https://stackoverflow.com/a/1472014/8411228
  • Pipfile: The way to go when you work in an virtualenv https://pipenv.kennethreitz.org/en/latest/
  • environment.yml: Used for Conda environments https://tdhopper.com/blog/my-python-environment-workflow-with-conda/#fn:requirements-conda

Another option: You can use PyInstaller to freeze (packages) Python applications into stand-alone executables, under Windows, GNU/Linux, Mac OS X, FreeBSD, Solaris and AIX.

PyInstaller Quickstart

This has worked very well for me. Indeed, you do not have to worry about whether the final user has Python installed.