0

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.

MatthewMartin
  • 32,326
  • 33
  • 105
  • 164
beta
  • 5,324
  • 15
  • 57
  • 99

2 Answers2

2

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.

dylrei
  • 1,728
  • 10
  • 13
  • what is a virtualenv? i know, i can google, but i think you could recommend any good introductory reads about virtualenv. thanks! – beta Jan 18 '15 at 18:23
  • 1
    @beta http://stackoverflow.com/questions/5844869/comprehensive-beginners-virtualenv-tutorial – dylrei Jan 19 '15 at 17:53
  • by the way, how i did it now: i just copied the script on my external server, and downloaded all the requirements/dependencies i needed. then created a cronjob and that's it. if i will deploy more python projects on this external server, i will surely check out virtualenv! – beta Jan 19 '15 at 19:06
-1

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.

Malik Brahimi
  • 16,341
  • 7
  • 39
  • 70
  • that's not really feasible for me. i don't want my laptop to run 24/7. i have access to real servers and want to make use of them. however, they run on different OS, etc... so i am thinking of an efficient way to deploy the python script, which i developed on my laptop on these external servers.. there must be a way, i'm sure. – beta Jan 18 '15 at 17:58
  • 1
    Perhps you can use SSH to connect to these servers and install Python and the other frameworks. – Malik Brahimi Jan 18 '15 at 17:59