回溯上的python路径django不正确

时间:2015-02-27 03:55:58

标签: python django mod-wsgi python-3.4

我在ubuntu服务器上使用apache2和mod wsgi以及virtualenv运行python3.4和django 1.7.5。我遇到了一个问题,我认为这是由django使用错误的python路径引起的。在这个视图中,我只是试图打印出python版本,因为我怀疑它是错误的。

公平警告:我是python,django,ubuntu和apache的新手。但我有其他系统管理员和编程方面的经验。因此,对于已经使用此堆栈一段时间的人来说,这个问题可能非常明显。如果是的话,我道歉。

这是追溯

Environment:

Django Version: 1.7.5
Python Version: 2.7.8
Installed Applications:
('django.contrib.admin',
 'django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'helloworld')
Installed Middleware:
('django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'django.middleware.clickjacking.XFrameOptionsMiddleware')


Traceback:
File "/var/www/unchained/lib/python3.4/site-packages/django/core/handlers/base.py" in get_response
111.                     response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/var/www/unchained/helloworld/views.py" in helloworld
7.     html = dict("<html><body><b>", "Django: ", django.get_version(), "<br>Python: ", sys.version)

Exception Type: TypeError at /
Exception Value: dict expected at most 1 arguments, got 5

主要错误:

TypeError at /

dict expected at most 1 arguments, got 5

Request Method:     GET
Request URL:    http://10.1.1.75/
Django Version:     1.7.5
Exception Type:     TypeError
Exception Value:    

dict expected at most 1 arguments, got 5

Exception Location:     /var/www/unchained/helloworld/views.py in helloworld, line 7
Python Executable:  /usr/bin/python
Python Version:     2.7.8
Python Path:    

['/var/www/unchained',
'/var/www/unchained/bin/python',
'/var/www/unchained/lib/python3.4/site-packages',
'/usr/lib/python2.7',
'/usr/lib/python2.7/plat-x86_64-linux-gnu',
'/usr/lib/python2.7/lib-tk',
'/usr/lib/python2.7/lib-old',
'/usr/lib/python2.7/lib-dynload',
'/usr/local/lib/python2.7/dist-packages',
'/usr/lib/python2.7/dist-pack

然而,当我

source bin/activate
python manage.py shell
>>>import sys
>>>print(sys.version)

我得到3.4.0 (default, Apr 11 2014, 13:05:11) [GCC 4.8.2]。这让我觉得django正在使用正确的virtualenv和正确的python。但是,为什么回溯会显示python 2.7.8 ??

我意识到我正在使用dict错误,我故意试图抛出错误来获取追溯。

这是我的apache虚拟主机减去我的个人信息

<VirtualHost *:80>
    Alias /robots.txt /var/www/static/robots.txt
    Alias /favicon.ico /var/www/static/favicon.ico
    Alias /static/ /var/www/unchained/Unchained/static/
    <Directory /var/www/unchained/Unchained/static>
            Order deny,allow
            Allow from all
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

    WSGIDaemonProcess example.com processes=2 threads=2 display-name=%{GROUP}
    WSGIProcessGroup example.com

    WSGIScriptAlias / /var/www/unchained/Unchained/wsgi.py

    <Directory /var/www/unchained/Unchained>
            <Files wsgi.py>
                    Order deny,allow
                    Allow from all
            </Files>
    </Directory>
</VirtualHost>

这个apache2设置是否正确地将wsgi和虚拟路径导入python?

我意识到这篇文章非常冗长,我道歉,但有一堆可以放在这里!!

由于

0 个答案:

没有答案