1

I have a python project which takes in a bunch of pdf files from a directory, scrapes data from them, and then does some matching of that scraped data with some data in a CSV file.

The whole work has 2-3 python scripts, used as modules, and also uses dependencies of pdftotext, pandas, NumPy, etc.

Now I can pip freeze my Conda env and it can give me a requirements.txt file with all packages to install.

However, I want this main python script (which calls other modules and runs the whole project) to be run by a less technical person who doesn't work on pandas and other such python stuff.

So is there a way I can make this whole project as an executable file that encapsulates all dependencies, packages, scripts, and just running that executable in the terminal should run the whole project without having the other person install all dependencies themselves using requirements.txt file.

I can't use docker unfortunately as that is not permitted right now for my work.

I was thinking buck build if that works?

https://buck.build/

or if there is an easy way?

Thanks!

6
  • Which OS would you want to execute the program on? Commented Jun 3, 2020 at 20:37
  • 2
    Does this answer your question? How to make a Python script standalone executable to run without ANY dependency? Commented Jun 3, 2020 at 20:38
  • What operating system are you using? Is the target operating system the same? Have you looked at the various tools to make executables, such as PyInstaller? Commented Jun 3, 2020 at 20:38
  • Have a look at PyInstaller or Nuitka. Commented Jun 3, 2020 at 20:38
  • macos or if run on server, then linux. But is it possible to run it on any os? Target OS would either be macos (if run on laptop). or Linux if run on server. Same as me. Commented Jun 3, 2020 at 21:10

2 Answers 2

1

One approach is to package the Python application directory as a .zip file and execute that. Zip files that have a __main__.py entry point can be run this way.

This can be done easily in version 2.6 and up. Additional “zipapp” support was added in 3.6.

The main challenge has to do with compatibility for non-pure-Python libraries. What you zip up needs to be compatible with the machine where it will be run.

Sign up to request clarification or add additional context in comments.

2 Comments

could u help broaden the above ans? What do u mean zip it using zipapp support? Is that a package which helps me zip the whole python project? The difference is the direcotry of pdf files are not going to be fixed. SO end user passes a directory path to the pdf files via cli and python script takes that via argparser and then does os.walk to scrape data etc.
Many good articles on this, e.g. gist.github.com/asimjalis/4237534. Try it and see how it works. This is 100% about the Python app, 0% about your input files — the app can process any input you want, just like in a non-zipped app.
0
pip install cx_freeze

cxfreeze main.py --target-name your_exe_name

Replace your_exe_name. It will generate a build folder with your .exe in it.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.