【问题标题】:Pycharm cant open manage.py taskPycharm 打不开 manage.py 任务
【发布时间】:2015-05-22 18:44:06
【问题描述】:

在我的一个项目中,我无法打开管理任务控制台。它适用于其他项目,但不适用于这个项目。它以前工作过,但最近停止了。我尝试使用该项目的旧版本,但它仍然损坏。我收到此错误:

    Failed to get real commands on module "Visdjango": python process died with code 1: Traceback (most recent call last):
  File "C:\Program Files (x86)\JetBrains\PyCharm 4.5.1\helpers\pycharm\manage_tasks_provider.py", line 22, in <module>
    parser.report_data(dumper)
  File "C:\Program Files (x86)\JetBrains\PyCharm 4.5.1\helpers\pycharm\django_manage_commands_provider\_parser\parser.py", line 40, in report_data
    module_to_use.process_command(dumper, command, command.create_parser("", command_name))
  File "C:\Program Files (x86)\JetBrains\PyCharm 4.5.1\helpers\pycharm\django_manage_commands_provider\_parser\_optparse.py", line 23, in process_command
    dumper.set_arguments(command.args)
  File "C:\Program Files (x86)\JetBrains\PyCharm 4.5.1\helpers\pycharm\django_manage_commands_provider\_xml.py", line 95, in set_arguments
    self.__command_element.setAttribute("args", VersionAgnosticUtils().to_unicode(command_args_text))
  File "C:\Program Files (x86)\JetBrains\PyCharm 4.5.1\helpers\pycharm\utils.py", line 36, in to_unicode
    return unicode(obj.decode("utf-8"))
AttributeError: 'list' object has no attribute 'decode'

【问题讨论】:

  • 从内存中您需要在 pycharm 中设置 manage.py 的路径 - 在工具栏中查找“编辑配置”菜单并查找“django”设置部分
  • 我已经设置了路径,所以不应该这样。但是,如果我可能遗漏了什么,你该怎么做呢?

标签: python django pycharm django-manage.py


【解决方案1】:

YOUR_PYCHARM_INSTALLATION_DIR\helpers\pycharm\django_manage_commands_provider\_parser\_utils.py 中更新您的 _utils.py

并更改第 20 行的代码:

assert isinstance(opt.choices, list), "Choices should be list"

assert isinstance(opt.choices, (list, tuple)), "Choices should be list or tuple"

【讨论】:

    【解决方案2】:

    安装version 4.5.3 RC

    如果您使用的是虚拟环境,请确保您的项目解释器(设置 > 项目:... > 项目解释器)指向其中的 python 可执行文件(例如,my_virtual_env/bin/python3.4)。

    如果您使用的是虚拟机,您还需要让您的项目解释器设置指向您的虚拟机下的虚拟环境下的python版本。如果您使用 Vagrant,这很容易,因为当您尝试添加新的解释器时,PyCharm 允许您选择 Vagrant,然后浏览 VM 文件系统以指向您需要的文件。

    【讨论】:

      【解决方案3】:

      这看起来像是 PyCharm 4.5 的新 manage.py 任务集成中的一个错误。请将此问题报告给PyCharm's issue tracker

      【讨论】:

      【解决方案4】:

      我今天也遇到了同样的问题。在调试 pycharm django 命令运行程序后,我发现了一些问题。 所以我项目中的问题是:

      1. 列表,而不是元组或集合。在用于选择选项的 django 命令中,我有时使用元组,有时使用列表。并且跑步者通常只与列表一起工作。如果您将使用任何其他结构进行选择,您将收到错误消息。您可以在 your_pycharm_dir/helpers/pycharm/django_manage_command_provider/_parse/_utils.py 字符串 26 assert isinstance(opt.choices, list), "Choices should be list" 中看到这一点
      2. 命令参数必须是字符串。如果你有这样的命令 class Command(BaseCommand): args= ['app_label', 'model_name', ] 你会得到一个错误。 Args 必须是字符串

      如果你想调试 pycharm django manage.py 任务运行器,你可以从 your_pycharm_dir/helpers/pycharm/manage_py_task_provider.py 开始。并在尝试中将解析器包装在字符串 22 处,除了 try: dumper = _xml.XmlDumper() parser.report_data(dumper) print(dumper.xml) except Exception: pass

      【讨论】:

        猜你喜欢
        • 2019-01-12
        • 1970-01-01
        • 2023-03-20
        • 2014-02-27
        • 1970-01-01
        • 2015-08-22
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多