如何在virtualenv中安装下载的django项目

时间:2018-03-14 20:04:22

标签: python django pip virtualenv

我正在尝试按照Django / Ajax教程中的说明进行操作:https://realpython.com/blog/python/django-and-ajax-form-submissions/。他们说:

这是我正在做的事情:

  1. 使用virtualenv -p /usr/bin/python3 ajaxenv文件夹
  2. 中的home/ajaxtutorial/创建新的virtualenv
  3. 下载repo并将其django-form-fun/part1/pre-ajax/talk_project/文件夹解压缩到home/ajaxtutorial文件夹中。
  4. 将下载的回购邮件提供的requirements.txt放入ajaxenv/bin
  5. 在ajaxenv中运行pip install -r requirements.txt。此时我可以看到Django已安装。
  6. 此时教程说“同步数据库”。我知道如何执行此操作的唯一方法是使用python manage.py migrate,但这会引发错误。我想这个方法需要首先启动项目或应用程序,这不是一个案例,因为应用程序和项目都是下载的,而不是由我创建的。

    我不知道如何从这里开始。 python manage.py migrate会抛出以下错误:

    Traceback (most recent call last):
      File "manage.py", line 10, in <module>
        execute_from_command_line(sys.argv)
      File "/home/bart/ajaxtutorial/ajaxenv/lib/python3.5/site-packages/django/core/management/__init__.py", line 399, in execute_from_command_line
        utility.execute()
      File "/home/bart/ajaxtutorial/ajaxenv/lib/python3.5/site-packages/django/core/management/__init__.py", line 392, in execute
        self.fetch_command(subcommand).run_from_argv(self.argv)
      File "/home/bart/ajaxtutorial/ajaxenv/lib/python3.5/site-packages/django/core/management/__init__.py", line 261, in fetch_command
        commands = get_commands()
      File "/home/bart/ajaxtutorial/ajaxenv/lib/python3.5/site-packages/django/core/management/__init__.py", line 107, in get_commands
        apps = settings.INSTALLED_APPS
      File "/home/bart/ajaxtutorial/ajaxenv/lib/python3.5/site-packages/django/conf/__init__.py", line 54, in __getattr__
        self._setup(name)
      File "/home/bart/ajaxtutorial/ajaxenv/lib/python3.5/site-packages/django/conf/__init__.py", line 50, in _setup
        self._configure_logging()
      File "/home/bart/ajaxtutorial/ajaxenv/lib/python3.5/site-packages/django/conf/__init__.py", line 72, in _configure_logging
        from django.utils.log import DEFAULT_LOGGING
      File "/home/bart/ajaxtutorial/ajaxenv/lib/python3.5/site-packages/django/utils/log.py", line 7, in <module>
        from django.views.debug import ExceptionReporter, get_exception_reporter_filter
      File "/home/bart/ajaxtutorial/ajaxenv/lib/python3.5/site-packages/django/views/debug.py", line 12, in <module>
        from django.template import Template, Context, TemplateDoesNotExist
      File "/home/bart/ajaxtutorial/ajaxenv/lib/python3.5/site-packages/django/template/__init__.py", line 53, in <module>
        from django.template.base import (ALLOWED_VARIABLE_CHARS, BLOCK_TAG_END,
      File "/home/bart/ajaxtutorial/ajaxenv/lib/python3.5/site-packages/django/template/base.py", line 19, in <module>
        from django.utils.html import escape
      File "/home/bart/ajaxtutorial/ajaxenv/lib/python3.5/site-packages/django/utils/html.py", line 14, in <module>
        from .html_parser import HTMLParser, HTMLParseError
      File "/home/bart/ajaxtutorial/ajaxenv/lib/python3.5/site-packages/django/utils/html_parser.py", line 12, in <module>
        HTMLParseError = _html_parser.HTMLParseError
    AttributeError: module 'html.parser' has no attribute 'HTMLParseError'
    

0 个答案:

没有答案