目录结构是这样的/venv#这是virtualenv创建的虚拟目录|--/bin|--/include`--/lib/myapp#这是我的flask应用地址|--wsgi.py在bash下运行venv/bin/activate后切换到虚拟环境,然后运行wsgi.py没有问题。但是,在sublimetext下点击【Tools】->【Build】提示出错,说找不到flask模块,flask模块是我在virtualenv下用pip安装的:Traceback(mostrecentcalllast):File"/Users/Toon/Code/myapp/wsgi.py",line4,infromflaskimportFlask,request,session,redirect,url_for,abort,\ImportError:Nomodulenamedflask[Finishedin0.1swithexitcode1]于是我想,这里Build应该没有导入virtualenv下的site-packages,在网上搜了到了这个答案http://stackoverflow.com/questions/11...按照他的方法,我对工程文件myapp.sublime-project进行了下列设置{"folders":[ { "path":"/Users/Toon/Code/myapp" }],"build_systems":[{"name":"RunTests","cmd":["source","/Users/Toon/Code/venv/bin/activate"],"working_dir":"/Users/Toon/Code/myapp","cmd":["python","wsgi.py"]}]}保存后build,仍然出现上面的错误提示,是不是site-packages荏苒没有被导入呢,问题出在哪了呢?
2 回答
牛魔王的故事
TA贡献1830条经验 获得超3个赞
你忘了指定python环境了和selecter了"build_systems":[{"name":"RunTests","env":{"PYTHONPATH":"/Users/Toon/Code/venv/bin/python:/Users/Toon/Code/venv/lib/python2.7/site-packages"},"cmd":["python","$file"],"selector":"source.python"}]这样就可以了,运行应该没问题了
添加回答
举报
0/150
提交
取消