您的位置:首页 > 运维架构

openshift:Perhaps your account does not have write access to this directory? You can change the cac

2013-01-03 00:00 736 查看
添加了pymongo之后重新部署程序,openshift 出现如下错误

File "/var/lib/openshift/0f9c019e8890400bb48af288d0307389/app-root/runtime/repo//diy/runapp.py", line 5, in <module>
from application import Application
File "/var/lib/openshift/0f9c019e8890400bb48af288d0307389/app-root/runtime/repo/diy/application.py", line 7, in <module>
import dbhelper
File "/var/lib/openshift/0f9c019e8890400bb48af288d0307389/app-root/runtime/repo/diy/dbhelper/__init__.py", line 5, in <module>
from dbhelper import *
File "/var/lib/openshift/0f9c019e8890400bb48af288d0307389/app-root/runtime/repo/diy/dbhelper/dbhelper.py", line 4, in <module>
from pymongo import MongoClient
File "build/bdist.linux-x86_64/egg/pymongo/__init__.py", line 61, in <module>
File "build/bdist.linux-x86_64/egg/pymongo/connection.py", line 39, in <module>
File "build/bdist.linux-x86_64/egg/pymongo/mongo_client.py", line 44, in <module>
File "build/bdist.linux-x86_64/egg/bson/__init__.py", line 41, in <module>
File "build/bdist.linux-x86_64/egg/bson/_cbson.py", line 7, in <module>
File "build/bdist.linux-x86_64/egg/bson/_cbson.py", line 4, in __bootstrap__
File "build/bdist.linux-x86_64/egg/pkg_resources.py", line 882, in resource_filename
The exception instance that caused extraction to fail
File "build/bdist.linux-x86_64/egg/pkg_resources.py", line 1351, in get_resource_filename

File "build/bdist.linux-x86_64/egg/pkg_resources.py", line 1373, in _extract_resource
# Convert a zipfile subpath into an egg-relative path part list
File "build/bdist.linux-x86_64/egg/pkg_resources.py", line 962, in get_cache_path

File "build/bdist.linux-x86_64/egg/pkg_resources.py", line 928, in extraction_error

pkg_resources.ExtractionError: Can't extract file(s) to egg cache

The following error occurred while trying to extract file(s) to the Python egg
cache:

[Errno 13] Permission denied: '/var/lib/openshift/0f9c019e8890400bb48af288d0307389/.python-eggs'

The Python egg cache directory is currently set to:

/var/lib/openshift/0f9c019e8890400bb48af288d0307389/.python-eggs

Perhaps your account does not have write access to this directory?  You can
change the cache directory by setting the PYTHON_EGG_CACHE environment
variable to point to an accessible directory.


分析原因是访问了某个不被允许的目录,由于使用的virtenv管理包,在openshift启动的时候已经设置了这项的值:

here = os.path.dirname(os.path.abspath(__file__))
os.environ['PYTHON_EGG_CACHE'] = os.path.join(here, '..', 'misc/virtenv/lib/python2.7/site-packages')
virtualenv = os.path.join(here, '..', 'misc/virtenv/bin/activate_this.py')
execfile(virtualenv, dict(__file__=virtualenv))


最后原因是需要在引用某些模块之前设置这个变量:

#!/usr/bin/env python
#-*- coding:utf-8 -*-
from setting import *
import os

here = os.path.dirname(os.path.abspath(__file__)) os.environ['PYTHON_EGG_CACHE'] = os.path.join(here, '..', 'misc/virtenv/lib/python2.7/site-packages') virtualenv = os.path.join(here, '..', 'misc/virtenv/bin/activate_this.py') execfile(virtualenv, dict(__file__=virtualenv))
from application import Application
import tornado.options
import tornado.httpserver
import tornado.ioloop


将后面的模块导入改下顺序就可以了。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐