首页 > 解决方案 > 尝试安装 Django reversion

问题描述

我正在尝试设置一个 Django 项目,但我得到了这个:

python2.7 manage.py migrate
Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 364, in execute_from_command_line
    utility.execute()
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 338, in execute
    django.setup()
  File "/usr/local/lib/python2.7/dist-packages/django/__init__.py", line 27, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "/usr/local/lib/python2.7/dist-packages/django/apps/registry.py", line 85, in populate
    app_config = AppConfig.create(entry)
  File "/usr/local/lib/python2.7/dist-packages/django/apps/config.py", line 94, in create
    module = import_module(entry)
  File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
    __import__(name)
ImportError: No module named reversion

所以我正在尝试安装 reversion,但在尝试安装时收到此错误消息enter code here

$sudo pip install django-reversion
Downloading/unpacking django-reversion
  Downloading django-reversion-3.0.7.tar.gz (67kB): 67kB downloaded
  Running setup.py (path:/tmp/pip_build_root/django-reversion/setup.py) egg_info for package django-reversion
    Traceback (most recent call last):
      File "<string>", line 17, in <module>
      File "/tmp/pip_build_root/django-reversion/setup.py", line 28, in <module>
        long_description=read('README.rst'),
      File "/tmp/pip_build_root/django-reversion/setup.py", line 19, in read
        with open(filepath, "r", encoding="utf-8") as f:
    TypeError: 'encoding' is an invalid keyword argument for this function
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):

  File "<string>", line 17, in <module>

  File "/tmp/pip_build_root/django-reversion/setup.py", line 28, in <module>

    long_description=read('README.rst'),

  File "/tmp/pip_build_root/django-reversion/setup.py", line 19, in read

    with open(filepath, "r", encoding="utf-8") as f:

TypeError: 'encoding' is an invalid keyword argument for this function

----------------------------------------
Cleaning up...
Command python setup.py egg_info failed with error code 1 in /tmp/pip_build_root/django-reversion
Storing debug log for failure in /home/tirengarfio/.pip/pip.log

我在 Ubuntu 16.04 和 python 2.7 上。

标签: djangopipdjango-reversion

解决方案


仅 Python3open()是在 3.0.6 版中添加的。尝试早期版本,3.0.5 或 3.0.4:

pip install django-reversion==3.0.5

或者

pip install django-reversion==3.0.4

推荐阅读