Forums

Always-On Tasks with a virtualenv

Hello! I'm trying to run my python application with the venv I have created. It's inside of the apps directory and not my .virtualenvs because I am pulling these files from my GitHub repo into python anywhere. I've tried this to specify my venv path but I got a No such file or directory error in my log. This is what my task looks like

source /home/username/myApplicationDir/thevirtualenv/bin/activate && 
python /home/username/myApplicationDir/applicationFile.py

I'm assuming I need to create a new venv within my .virtualenvs folder but I'm not sure how I would "clone" the venv I already have in the application directory.

I've made some changes to my always on task location. Here is the updated version.

source /home/username/myApplicationDir/thevirtualenv/Scripts/activate &&
python3.9 /home/username/myApplicationDir/applicationFile.py

This is now the error I keep receiving in the log.

Nov 21 23:30:15 /home/username/myApplicationDir/thevirtualenv/Scripts/activate: line 4: syntax error near unexpected token `$'{\r''
Nov 21 23:30:15 /home/username/myApplicationDir/thevirtualenv/Scripts/activate: line 4: `deactivate () {#015'

I'm not sure where to go from here because the most i can find on this type of error is something to do with my wsgi file for venv variables but I don't think that applies for the application since it's not a web app.

I'd suggest to recreate the virtual environment on PythonAnywhere instead of pulling it from outside.