Virtualenv issue with flask-werkzeug

1.2k Views Asked by At

I have installed virtualenv along with flask, werkzeug, jinja2 and SQLAlchemy. I was following the tutorial mentioned on the flask website and i came across the below error when executing flask code

 Traceback (most recent call last):
  File "hello.py", line 1, in ?
    from flask import Flask
  File "/root/myproject/env/lib/python2.4/site-packages/Flask-0.7dev_20110211-py2.4.egg/flask/__init__.py", line 18
    from .app import Flask, Request, Response
         ^

What i feel is that virtualenv contains python 2.4 and in the documentation of flask it is mentioned that flask supports python 2.5. So maybe that might be the problem or it might be someother issue. Please help me out on this.

Secondly i would like to know the process of getting the latest virtualenv which has Python 2.7 or any tips on how to install it on virtualenv.

I am using CentOS

Thank You in Advance

4

There are 4 best solutions below

3
On BEST ANSWER

dunno what you did and how old your virtualenv is .. but you make your own virtualenv by:

% python -c "import urllib, os; os.mkdir('py-env'); \
     urllib.urlretrieve('http://goo.gl/D2RB', 'py-env/virtualenv.py')"
% python py-env/virtualenv.py --no-site-packages py-env
% source py-env/bin/activate
% pip install flask SQLAlchemy 

that should work. virtualenv itself does not 'contain python'. do you run the correct version of python (dunno whats installed on your distro)?

0
On
1
On

The import .module syntax is introduced in Python 2.5 (relative import). So you have to use at least 2.5 for this thing.

0
On

So can we clarify what is meant when they say "virtualenv itself has no python" take a look in the corresponding bin/ or /lib directories when a env is created or what about the fact one can supply the -p flag when creating a virtualenv -p python2.7. So do as fear_matrix did, install the required python and then create a virtualenv with it "virtualenv -p python2.7". Maybe this is different on centos but I wouldn't think so.