Django admin OSError(错误的Python路径)

时间:2013-09-13 14:42:46

标签: python django pythonpath

我正在尝试在django admin中上传图片并获取OSError(权限被拒绝)。

这是日志:

Request Method: POST
Request URL:    .........
Django Version: 1.5.3
Exception Type: OSError
Exception Value:
[Errno 13] Permission denied: .......
Exception Location: /usr/lib/python2.6/os.py in makedirs, line 157
Python Executable:  /usr/bin/python
Python Version: 2.6.5
Python Path:
['/home/deployer/virtualenvs/python-2.7.5/lib/python2.7/site-packages',
 '/usr/lib/python2.6',
 '/usr/lib/python2.6/plat-linux2',
 '/usr/lib/python2.6/lib-tk',
 '/usr/lib/python2.6/lib-old',
 '/usr/lib/python2.6/lib-dynload',
 '/usr/lib/python2.6/dist-packages',
 '/usr/lib/python2.6/dist-packages/PIL',
 '/usr/lib/python2.6/dist-packages/gst-0.10',
 '/usr/lib/pymodules/python2.6',
 '/usr/lib/python2.6/dist-packages/gtk-2.0',
 '/usr/lib/pymodules/python2.6/gtk-2.0',
 '/usr/local/lib/python2.6/dist-packages',
 ..........]

TRACEBACK:
...........
    /home/deployer/virtualenvs/python-2.7.5/lib/python2.7/site-packages/django/core/files/storage.py in _save
    *171. os.makedirs(directory)*
    /usr/lib/python2.6/os.py in makedirs
    *150. makedirs(head, mode)* 
    /usr/lib/python2.6/os.py in makedirs
    *157. mkdir(name, mode)* 

在我看来,问题在于错误的python路径。但我显然无法改变它。

任何想法如何解决这个问题?

1 个答案:

答案 0 :(得分:2)

我安装了mod_wsgi和mod_python。因此,尽管我对mod_wsgi进行了配置,但mod_python首先进行了初始化,并使Apache使用旧版本的Python。这导致了所有权限问题。

请参阅此文档:https://code.google.com/p/modwsgi/wiki/InstallationIssues#Python_Version_Mismatch