将Django项目从python2转换为python3:pip3安装Django\u注释namererror unicode

2024-09-30 22:15:04 发布

您现在位置:Python中文网/ 问答频道 /正文

系统信息:64位OS-X,Python 3.7

我正在将Django网站从Python2转换为Python3。然后我在settings.py的INSTALL\u APPS中安装了所有必需的模块,除了一个:django\u comments

(env) user:languages user$ pip3 install django_comments
Collecting django_comments
  Using cached https://files.pythonhosted.org/packages/c7/df/3a752f3e393b470087304dd47be6a4bad9867e7ec33963ff022d32143700/django-comments-1.0.0.b.tar.bz2
    ERROR: Command errored out with exit status 1:
     command: /Users/user/.../env/bin/python3 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/tb/vbtzyvv92hz6262qv7x8r8jh0000gn/T/pip-install-xjv_0ird/django-comments/setup.py'"'"'; __file__='"'"'/private/var/folders/tb/vbtzyvv92hz6262qv7x8r8jh0000gn/T/pip-install-xjv_0ird/django-comments/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base pip-egg-info
         cwd: /private/var/folders/tb/vbtzyvv92hz6262qv7x8r8jh0000gn/T/pip-install-xjv_0ird/django-comments/
    Complete output (7 lines):
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/private/var/folders/tb/vbtzyvv92hz6262qv7x8r8jh0000gn/T/pip-install-xjv_0ird/django-comments/setup.py", line 12, in <module>
        version = get_version(),
      File "/private/var/folders/tb/vbtzyvv92hz6262qv7x8r8jh0000gn/T/pip-install-xjv_0ird/django-comments/django_comments/__init__.py", line 4, in get_version
        return u'.'.join(map(unicode, VERSION))
    NameError: name 'unicode' is not defined
    ----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

我发现这个may be related to compatibility with Python 3和一个潜在的修复方法是用str替换unicode。但是,这是我想在Python3中使用的一个模块,因为Django项目目前依赖于这个模块进行注释。它是否已经被弃用了,除了自己重新配置它之外,根本没有办法工作?谢谢你


Tags: 模块installpipdjangopyeggvarsetup