鼻子/Nosegae:进口问题
我有这个问题,它让我发疯!
所以我正在开发我的第一个真正的 Google App Engine 应用程序,我总是喜欢在编写测试时发现一些东西。
所以我有以下设置:
我有一个带有nose、nosegae、webtest 和gaetestbed 的virtualenv。它的名字叫porksvr。
我像这样激活我的virtualenv:
source porksvr/bin/activate
要运行nose,我使用以下命令:
nosetests --with-gae --gae-lib-root /home/fs/gae
这给了我以下错误
DEBUG: Access to module file denied:
/home/fs/work/gaecode/porksvr/lib/python2.6/site-packages/webtest
所以一开始我想“好吧,nose正在dev_appserver的'上下文'中运行应用程序,所以它不知道网络测试”。
但可以肯定的是,我创建了一个新目录并添加了一个小型 GAE 应用程序。只有 3 个文件:
-main.py
-app.yaml
-test_huh.py (导入 webtest 模块。)
现在真正让我困惑的是,这竟然可以工作。我运行了nosetests cmd,它实际上通过了我的测试。
所以我开始深入研究我的应用程序,找出可能有什么不同,但我真的碰壁了。
我首先认为这可能是一个权限问题,因为错误显示“访问...被拒绝”,但我真的找不到任何特别的东西。接下来我想也许是因为我在 virtualenv 之前创建了我的应用程序,但我真的不明白这怎么会成为一个问题。
因此,如果有人知道为什么会发生这种情况,我将非常感激。
I have this problem and it's drivin' me nuts!
So I am developing my first real Google App Engine application and I always like to discover things while writing tests.
So I have the following setup:
I have a virtualenv with nose, nosegae, webtest and gaetestbed. It's called porksvr.
I activate my virtualenv like this:
source porksvr/bin/activate
To run nose I use the following command:
nosetests --with-gae --gae-lib-root /home/fs/gae
This gives me the following error
DEBUG: Access to module file denied:
/home/fs/work/gaecode/porksvr/lib/python2.6/site-packages/webtest
So at first I thought "okay, nose is running the application in the 'context' of the dev_appserver so it doesn't know about webtest".
But to be sure I created a new directory and added a small GAE application. It's just 3 files:
-main.py
-app.yaml
-test_huh.py ( imports the webtest module. )
Now what really confused me is that this just works. I run the nosetests cmds and it's actually passing my tests.
So I started digging in my application to find out what could be different but I really hit a wall.
I first thought that it might be a permission problem since the error says 'access ...denied' but I couldn't really find anything special. Next I thought maybe it's because I created my application before the virtualenv but I couldn't really see how this can be a problem.
So if anybody has a clue why this happens I would be really really grateful.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Nose-GAE 在使用 virtualenv 时存在一些已记录的问题。
您可以尝试使用鼻子的
--without-sandbox
标志。Nose-GAE has some documented issues when you're using virtualenv.
You might try using using nose's
--without-sandbox
flag.太好了,经过几个小时的尝试,我实际上在问这个问题后就解决了我的问题。
解决这个问题的方法是使用以下开关
--no-site-packages
创建 virtualenv。显然,我系统的 Python 中有一个 webtest 副本,它以某种方式给我的 virtualenv 带来了问题。当我尝试在我的 virtualenv 中 pip install webtest 时,我应该注意到它,它说它已经存在。仍然不能 100% 确定为什么有些应用程序可以运行,而另一些则不能。
Great so after hours of trying I actually just solved my problem right after asking this question.
What fixed it was to create the virtualenv with the following switch
--no-site-packages
. Apparently I had a copy of webtest in my system's Python that somehow gave problems with my virtualenv. I should have noticed it when I tried to pip install webtest in my virtualenv and it said it already existed.Still not 100% sure why some apps worked and others didn't.