我为Python3(Ubuntu 18.04 LTS)安装了Django 2.1.7和mod-wsgi。之后,我将以下配置参数添加到apache2服务器的apache2.conf文件中:
WSGIScriptAlias / /var/www/html/mysite/mysite/wsgi.py
WSGIPythonPath /var/www/html/mysite
WSGIPythonHome /usr/
<Directory /var/www/html/mysite/>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
mysite Django项目只是一个默认的示例项目。当我访问www..com / test时,它返回以下错误消息:
ImportError at /admin
cannot import name 'path'
Request Method: GET
Request URL: http://<sitename>.com/test
Django Version: 1.11.11
Exception Type: ImportError
Exception Value:
cannot import name 'path'
Exception Location: /var/www/html/mysite/mysite/urls.py in <module>, line 17
Python Executable: /usr/bin/python3
Python Version: 3.6.7
Python Path:
['/var/www/html/mysite',
'/usr/lib/python36.zip',
'/usr/lib/python3.6',
'/usr/lib/python3.6/lib-dynload',
'/usr/local/lib/python3.6/dist-packages',
'/usr/lib/python3/dist-packages']
但是如果我执行“
python3 -m django --version
”,它向我显示了正确的安装版本(2.1.7)。我还检查了服务器上是否安装了另一个(旧的)Django版本,但找不到任何内容。那么,为什么Apache或Django说版本1.11.11解决方案是什么样的?