OSX / Apache ModuleNotFoundError:没有名为'编码的模块'

时间:2017-09-27 01:45:58

标签: django macos apache python-3.x mod-wsgi

我有一个本地Django应用程序,我已经开发了一段时间。今天,经过大约一个月的工作,我回到了它,但它不会加载。检查apache错误日志,我一遍又一遍地看到以下内容:

Current thread 0x00007fffc0be23c0 (most recent call first):
[Tue Sep 26 19:18:09.154141 2017] [core:notice] [pid 1590] AH00052: child pid 1651 exit signal Abort trap (6)
Fatal Python error: Py_Initialize: unable to load the file system codec
ModuleNotFoundError: No module named 'encodings'

我上次参与项目时,我对项目代码进行了一些更改,但没有触及我的apache或mod_wsgi配置。

我的PYTHONPATH没有设定(也不是一个月前一切正常的时候设定的。这是我的mod_wsgi配置(再次没有改变):

WSGIDaemonProcess secureDash python-path=/Users/user/projects/secureDash_project python-home=/Users/user/.venvs/securedash_py3.6
WSGIProcessGroup secureDash
WSGIScriptAlias / /Users/user/projects/secureDash_project/config/wsgi.py

我花了很多时间在谷歌搜索这个问题,但似乎没有一个常见的修复方法适用。寻找关于其他地方的一些指导。

1 个答案:

答案 0 :(得分:0)

我发现,在我的virtualenv中:

workon securedash_py3.6

尝试运行python控制台时遇到错误:

(securedash_py3.6) user conf $ python3
dyld: Library not loaded: @executable_path/../.Python
  Referenced from: /Users/user/.venvs/securedash_py3.6/bin/python3
  Reason: image not found
Abort trap: 6

搜索该错误指向我this SO主题,最终解决了我的问题。基本上我用自制软件完成了一些必须打破我的venv中的符号链接的东西。以下是我要解决的具体命令:

find ~/.venvs/securedash_py3.6/ -type l -delete

然后cd到virtualenv目录:

$ cd ~/.venvs/securedash_py3.6
$ virtualenv .
Using base prefix '/usr/local/Cellar/python3/3.6.2/Frameworks/Python.framework/Versions/3.6'
Overwriting /Users/user/.venvs/securedash_py3.6/lib/python3.6/orig-prefix.txt with new content
New python executable in /Users/user/.venvs/securedash_py3.6/bin/python3.6
Also creating executable in /Users/user/.venvs/securedash_py3.6/bin/python
Installing setuptools, pip, wheel...done.

一切都很好。