Forums

How do I run a script in my virtualenv?

I created a virtualenv for my webapp. But I also want to be able to run a separate script in that virtualenv (for testing purposes). How do I run a script in my virtualenv?

And the reverse question too: How do I try running my webapp outside my virtualenv?

Thanks for any help. I'm a new to pythonanywhere and a newb to full stack programming.

That depends on how you created your virtualenv. eg: with virtualenvwrapper you can do a workon my-virtual-env from within a bash console to enter the virtualenv (then anything you run after that will be using your virtualenv python). Alternatively, if you already have the virtualenv setup on your web tab, you can go to the web tab and click on the link to open a console which is already within your virtualenv. This may be easier for you.

Any new consoles that did not have the virtualenv explicitly invoked will be outside of your virtualenv. Check this by doing a which python from within your virtualenv and outside of it and comparing the differences.