我正在尝试使用Python3.3在我的服务器上运行Django1.6b2 我现在遇到很多问题,我无法列出它们(Flup,Threading,FastCGI),最后我几乎就在那里。这是我的django.fcgi:
#!/home/benjamin/Python/3.3/bin/python3
import os, sys
import django
print("Django Version : {}".format(django.VERSION))
print("Python Version : {}".format(sys.version[:3]))
_PROJECT_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
sys.path.insert(0, _PROJECT_DIR)
sys.path.insert(0, os.path.dirname(_PROJECT_DIR))
_PROJECT_NAME = _PROJECT_DIR.split('/')[-1]
os.environ['DJANGO_SETTINGS_MODULE'] = "%s.settings" % _PROJECT_NAME
from django.core.servers.fastcgi import runfastcgi
runfastcgi(method="threaded", daemonize="false")
这是我的追溯:
Traceback (most recent call last):
File "website/public/django.fcgi", line 17, in <module>
runfastcgi(method="threaded", daemonize="false")
File "/home/benjamin/Python/3.3/lib/python3.3/site-packages/django/core/servers/fastcgi.py", line 143, in runfastcgi
from django.core.servers.basehttp import get_internal_wsgi_application
File "/home/benjamin/Python/3.3/lib/python3.3/site-packages/django/core/servers/basehttp.py", line 25, in <module>
from django.core.wsgi import get_wsgi_application
File "/home/benjamin/Python/3.3/lib/python3.3/site-packages/django/core/wsgi.py", line 1, in <module>
from django.core.handlers.wsgi import WSGIHandler
File "/home/benjamin/Python/3.3/lib/python3.3/site-packages/django/core/handlers/wsgi.py", line 9, in <module>
from django import http
File "/home/benjamin/Python/3.3/lib/python3.3/site-packages/django/http/__init__.py", line 4, in <module>
from django.http.response import (HttpResponse, StreamingHttpResponse,
File "/home/benjamin/Python/3.3/lib/python3.3/site-packages/django/http/response.py", line 17, in <module>
from django.utils import six, timezone
File "/home/benjamin/Python/3.3/lib/python3.3/site-packages/django/utils/timezone.py", line 11, in <module>
import pytz
File "<frozen importlib._bootstrap>", line 1567, in _find_and_load
File "<frozen importlib._bootstrap>", line 1534, in _find_and_load_unlocked
File "/home/benjamin/modules/pytz-2013b-py2.6.egg/pytz/__init__.py", line 1103, in <module>
File "/home/benjamin/modules/pytz-2013b-py2.6.egg/pytz/__init__.py", line 1103, in <listcomp>
File "/home/benjamin/modules/pytz-2013b-py2.6.egg/pytz/__init__.py", line 107, in resource_exists
File "/home/benjamin/modules/pytz-2013b-py2.6.egg/pytz/__init__.py", line 100, in open_resource
File "/nfs/http7/benjamin/Python/distribute-0.7.3/pkg_resources.py", line 949, in resource_stream
self, resource_name
File "/nfs/http7/benjamin/Python/distribute-0.7.3/pkg_resources.py", line 1379, in get_resource_stream
return StringIO(self.get_resource_string(manager, resource_name))
File "/nfs/http7/benjamin/Python/distribute-0.7.3/pkg_resources.py", line 1956, in StringIO
return StringIO(*args,**kw)
TypeError: initial_value must be str or None, not bytes
我该如何解决?似乎Django尝试导入一个我用pip-3.3找不到的模块(pytz-2013b-py2.6.egg)它是2.6,为什么pip安装呢?的xD
有人可以帮助我吗? =)
答案 0 :(得分:2)
在以下位置看起来像python3的分发包中的错误 -
pkg_resources.py - &gt; get_resource_string 此方法返回字节,StringIO期望字符串。 我尝试使用decode(“ISO-8859-1”)方法解码它然后我在pytz包中出错。
但是我得到了解决方法 -
将“./pytz-2013.7-py3.3.egg”更改为“./pytz” “site-packages / easy-install.pth”文件。
确保您的站点包中有解压缩的pytz目录 。目录