1.安装virtualenv
参照:http://docs.jinkan.org/docs/flask/installation.html
2.PyCharm结合virtualenv开发应用
PyCharm-->New Project -->Pure Python-->Interpreter中的设置中选择Create VirtualEnv选择相应的目录,例如:~/PycharmProjects/pycharm_env/test,PyCharm会依据项目名称在test目录下创建一个与项目名同名的目录,我这里是flask_mysql,然后激活环境:
# 激活
source bin/activate
# 先virtualenv下安装插件 pip install Flask pip install Flask-Script pip install Flask-Restless pip install Flask-SQLAlchemy
# 运行项目
python ~/PycharmProjects/falsk_mysql/manage.py runserver
http://www.cnblogs.com/tk091/p/3700013.html
3. python python-eggs异常解决办法
参照:http://blog.csdn.net/livefun/article/details/10222771
4.virtualenv下import MySQLdb失败,但是正常情况下可以,解决方案:在virtualenv下安装MySQL-python
cd flask_mysql/
ls
git clone https://github.com/jehiah/mysql-python.git
ls
cd mysql-python/
ls
python setup.py build
python setup.py install
在virtualenv下import MySQLdb就没有错误了。
受启发:https://geert.vanderkelen.org/2014/mysql-connectorpython-on-github/
https://github.com/jehiah/mysql-python