简体   繁体   中英

How do I deploy a python application to an external server?

I have written a python script on my local laptop which uses several third party packages. I now want to run my script regularly (via a cron job) on an external server.

The external server most likely does not have all the dependencies installed, is there is a way to package and deploy my python script and dependencies in order to ensure that it will run?

I have already tried to package the script as an exe, but failed to do so.

Not clear what kind of third party packages you have, but for those that were installed with pip, you can do this in your dev environment:

$ pip freeze > requirements.txt

And then you can install these packages in your production environment:

$ pip install requirements.txt

Ideally, you will already have a virtualenv on your production box. If not, it may be well worth reading about these before deploying your script.

Just turn your computer into a server. Simply set up your router for port forwarding so that your server's content's will display when the router's IP is entered. You can of course purchase a DNS domain to give that IP a human readable URL.

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