- Alexei
- Aug 16, 2007
-
|
This code
code:import sys
#TB I need to setup virtual env
activate_this = '/home/huhu/.virtualenvs/wv_venv/bin/activate_this.py'
exec(activate_this, dict(__file__=activate_this))
sys.path.append('/home/tbumgarner/webapps/chs_web_viewer/web_viewer')
import app as application
is leading to this error. I for the life of me have no idea why this is happening.
code:[Sun Mar 12 20:10:50.924896 2017] [wsgi:error] [pid 7297:tid 139694796572416] [remote 127.0.0.1:50826]
exec(activate_this, dict(__file__=activate_this))
File "<string>", line 1
/home/huhu/.virtualenvs/wv_venv/bin/activat$
^
SyntaxError: invalid syntax
I was following this tutorial and had to change the execfile() command for python3.
Check the documentation for python 3's exec(): https://docs.python.org/3/library/functions.html#exec
"This function supports dynamic execution of Python code. object must be either a string or a code object. If it is a string, the string is parsed as a suite of Python statements which is then executed (unless a syntax error occurs)."
So the problem is that you're passing the string "/home/huhu/.virtualenvs/wv_venv/bin/activate_this.py'" to the exec() function, which is just a path and not really python code, hence the syntax error.
|
#
¿
Mar 12, 2017 21:54
|
|
- Adbot
-
ADBOT LOVES YOU
|
|
#
¿
May 5, 2024 03:23
|
|