以root权限执行python时候脚本时候报错“ExtractionError: Can't extract file(s) to egg cache”

错误日志:

*** Operational MODE: preforking ***
Traceback (most recent call last):
  File "./rf_automation/__init__.py", line 4, in <module>
    from .celery import ceapp as celery_app
  File "./rf_automation/celery.py", line 4, in <module>
    from celery import Celery, platforms
  File "/app/python2.7/lib/python2.7/site-packages/celery-3.1.25-py2.7.egg/celery/platforms.py", line 33, in <module>
    from .utils.functional import uniq
  File "/app/python2.7/lib/python2.7/site-packages/celery-3.1.25-py2.7.egg/celery/utils/__init__.py", line 25, in <module>
    from kombu.entity import Exchange, Queue
  File "/app/python2.7/lib/python2.7/site-packages/kombu-3.0.37-py2.7.egg/kombu/entity.py", line 13, in <module>
    from .serialization import prepare_accept_content
  File "/app/python2.7/lib/python2.7/site-packages/kombu-3.0.37-py2.7.egg/kombu/serialization.py", line 397, in <module>
    register_msgpack()
  File "/app/python2.7/lib/python2.7/site-packages/kombu-3.0.37-py2.7.egg/kombu/serialization.py", line 367, in register_msgpack
    import msgpack
  File "build/bdist.linux-x86_64/egg/msgpack/__init__.py", line 25, in <module>
  File "build/bdist.linux-x86_64/egg/msgpack/_packer.py", line 7, in <module>
  File "build/bdist.linux-x86_64/egg/msgpack/_packer.py", line 4, in __bootstrap__
  File "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 1136, in resource_filename
  File "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 1642, in get_resource_filename
  File "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 1672, in _extract_resource
  File "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 1203, in get_cache_path
  File "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 1183, 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: '/root/.cache'

The Python egg cache directory is currently set to:

  /root/.cache/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.

unable to load app 0 (mountpoint='') (callable not found or import error)
*** no app loaded. going in full dynamic mode ***
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI master process (pid: 32535)
spawned uWSGI worker 1 (pid: 32541, cores: 1)
spawned uWSGI worker 2 (pid: 32542, cores: 1)
spawned uWSGI worker 3 (pid: 32543, cores: 1)

  

问题分析:import msgpack时报错,提示无权限

解决办法为:

修改

import msgpack

  

为:

import os

os.environ['PYTHON_EGG_CACHE'] = '/tmp'

import msgpack

  

即可!

posted @ 2020-10-13 15:06  垄上行  阅读(338)  评论(0编辑  收藏  举报