mod_wsgi: ImportError: No module named 'encodings'

前端 未结 3 1486
伪装坚强ぢ
伪装坚强ぢ 2020-12-06 00:42

I\'m using Apache 2.2.15 on CentOS 6.5. I\'m trying to set up a Django app using mod_wsgi. I\'m using a virtual environment, and mod_wsgi was configured with --with-py

3条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-06 01:04

    On Windows, I solved this problem by putting the Lib directory of my Python installation directly on the PYTHONPATH. This is necessary even though, if you run Python directly in the same shell, it doesn't require this to find the encodings package:

    set PYTHONPATH=C:\WinPython-64bit-3.4.4.6Qt5\python-3.4.4.amd64\Lib;%PYTHONPATH%
    c:\apache24\bin\httpd.exe
    

    Also be sure to use the correct mod_wsgi version. I downloaded mine from the Unofficial Binaries page and chose it to match the Python (64 bit 3.4 in the example above). My website works correctly with Python after the above change to the .bat file starting Apache.

    Note my version of Python, WinPython, is installed by unzipping the install and placing it in the C: drive. Thus is it not installed in the Registry in the usual Windows way, which should minimize Registry interaction considerations.

提交回复
热议问题