Skip to main content
added 325 characters in body; edited tags
Source Link
Lynob
  • 4.5k
  • 13
  • 50
  • 75

how How to activate virtualenvVirtualenv when a pythonPython script starts?

I want to schedule a python script to run using cron on certain dates, the problem is that in order for example.py to work, example-env has to be activated, is there a way to make example.py activate its own virtualenv whenever cron execute it?

if not, then do iI have to create a bash script bash.sh that contains

#!/usr/bin/env bash
workon example-env
python2 example.py

and then schedule that to be executed by cron on certain dates? Or do I have to do something else?

Both ways are fine with me, I just want to know the correct way to do it. Perhaps I prefer the bash script method, since I have many Python files to run, so if I put them all inside a bash script and schedule that, it seems easier for me, but again I don't know the correct way to do it, therefore I'm asking for advice.

how to activate virtualenv when a python script starts?

I want to schedule a python script to run using cron on certain dates, the problem is that in order for example.py to work, example-env has to be activated, is there a way to make example.py activate its own virtualenv whenever cron execute it?

if not, then do i have to create a bash script bash.sh that contains

#!/usr/bin/env bash
workon example-env
python2 example.py

and then schedule that to be executed by cron on certain dates? Or do I have to do something else?

How to activate Virtualenv when a Python script starts?

I want to schedule a python script to run using cron on certain dates, the problem is that in order for example.py to work, example-env has to be activated, is there a way to make example.py activate its own virtualenv whenever cron execute it?

if not, then do I have to create a bash script bash.sh that contains

#!/usr/bin/env bash
workon example-env
python2 example.py

and then schedule that to be executed by cron on certain dates? Or do I have to do something else?

Both ways are fine with me, I just want to know the correct way to do it. Perhaps I prefer the bash script method, since I have many Python files to run, so if I put them all inside a bash script and schedule that, it seems easier for me, but again I don't know the correct way to do it, therefore I'm asking for advice.

Source Link
Lynob
  • 4.5k
  • 13
  • 50
  • 75

how to activate virtualenv when a python script starts?

I want to schedule a python script to run using cron on certain dates, the problem is that in order for example.py to work, example-env has to be activated, is there a way to make example.py activate its own virtualenv whenever cron execute it?

if not, then do i have to create a bash script bash.sh that contains

#!/usr/bin/env bash
workon example-env
python2 example.py

and then schedule that to be executed by cron on certain dates? Or do I have to do something else?