在debian服务器上以root权限执行python时候脚本时候。
得到如下错误
Traceback (most recent call last): File "server.py", line 10, in <module> from logic import Logic File "/var/opt/sameway/chatserver/logic.py", line 9, in <module> from db import DBEngine , DBUser , DBRelationship, DBOfflineMsg, DBOfflineAddFriend File "/var/opt/sameway/chatserver/db.py", line 5, in <module> import sqlalchemy File "build/bdist.linux-i686/egg/sqlalchemy/__init__.py", line 50, in <module> File "build/bdist.linux-i686/egg/sqlalchemy/types.py", line 26, in <module> File "build/bdist.linux-i686/egg/sqlalchemy/processors.py", line 109, in <module> File "build/bdist.linux-i686/egg/sqlalchemy/cprocessors.py", line 7, in <module> File "build/bdist.linux-i686/egg/sqlalchemy/cprocessors.py", line 4, in __bootstrap__ File "build/bdist.linux-i686/egg/pkg_resources.py", line 914, in resource_filename """Return specified resource as a string""" File "build/bdist.linux-i686/egg/pkg_resources.py", line 1601, in get_resource_filename subname = fullname.split(".")[-1] File "build/bdist.linux-i686/egg/pkg_resources.py", line 1657, in _extract_resource try: File "build/bdist.linux-i686/egg/pkg_resources.py", line 960, 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 2] No such file or directory: '/root/.python-eggs' The Python egg cache directory is currently set to: /root/.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.
下面提示是无访问权限
google得到解决方案http://davidwalsh.name/python-eggs
解决方法
import sqlalchemy
import os os.environ['PYTHON_EGG_CACHE'] = '/tmp' import sqlalchemy