简体   繁体   中英

How to make a Python project executable?

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!

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM