Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Alexei
Aug 16, 2007

huhu posted:

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.

Adbot
ADBOT LOVES YOU

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply