开发者

Virtualenv issue with flask-werkzeug

I have installed virtualenv along with flask, werkzeug, jinja2 and SQLAlchemy. I was following the tutorial mentioned on the fla开发者_高级运维sk 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


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


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)?


There are a couple of posts below which should help:

http://cols-code-snippets.blogspot.com/2011/02/start-new-python-project-with.html

http://cols-code-snippets.blogspot.com/2011/02/my-take-on-flask-application-skeleton.html



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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜