What is the Python egg cache (PYTHON_EGG_CACHE)?

后端 未结 8 625
我寻月下人不归
我寻月下人不归 2020-12-04 16:23

I\'ve just upgraded from Python 2.6.1 to 2.6.4 on my development machine and upon starting a python script was presented with the following message:

C

8条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-04 16:50

    This is a dark side-effect of using otherwise nice eggs mechanism.

    Eggs are packages (a directory full of files) packed into one .egg file to simplify depolyment.

    They are stored in /site-packages/ dir.

    As long as the files stored in the egg are .py files it works great. Python import can import things from any file-like object just like it was an ordinary file.

    But when something like .so happens to drop in there, python cannot explain to the underlying OS that it wants to load an library which doesn't have a physical name. And the only workaround distutils authors have thought of is unzipping it into a temp dir. Naturally it is not /site-packages/ since /site-packages/ is not writable for ordinary users.

    So you can either

    • set PYTHON_EGG_DIR to /tmp, or

    • give user www write permission to /var/www/.python-eggs
      (so that the files don't get unzipped every time /tmp is cleaned up) or better then

    • unzip the egg as suggested by @shalley303
      (and avoid unzipping of the egg in the run-time altogether).

提交回复
热议问题