How to deploy python script?
I want to round-up this question by suggesting a couple of ways to deploy Python Script or Models:
- Docker: This is one of the most popular way of hosting scripts and deploying Machine Learning Models online. You can use Docker to containerize the code and host it as a micro service using different apps.
- PEX: PEX is a clever tool being developed at Twitter that allows Python code to be shipped as executable zip files.
- AWS: Using AWS, you can create a free account and get started with hosting/deployment. Lot of resources availabel online.
- PYSimple, Pyinstaller and Sparrow: As mentioned in the answers above, we can use these packages also to do the task. Please read above.
- Flask App: If you dont want to use Docker, using simple flask app, you will be able to host your script online. But there will be a lot of issues as its not containerized. Best to use Docker.
- py2exe: If you are looking to convert python file into windows executable, Click here
- cx_Freeze: Similar to the py2exe, you can use this also
I will keep adding more content as I find them, but I think the best way to do it using DOCKER. Hope this helps.
PyInstaller is a powerful opensource tool for cross-platform deployment/distribution of python project.
*Note: Although I have no experience on distributing Jupyter Notebook with PyInstaller, but it seems to be plausible with this guide.
Install through pypi:
pip install pyinstaller
Distribution of code without console can be as simple as:
pyinstaller --noconsole script.py
Then you can find your .exe(Window) under dist folder of your working directory.
For the sake of completeness, dh-virtualenv by Spotify should be mentioned which enables packaging python code as a debian-package.
As a starting point, one could use this Blogpost: How We Deploy Python Code