7

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

    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'
4

4 回答 4

3

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

并更改第 20 行中的代码:

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

assert isinstance(opt.choices, (list, tuple)), "Choices should be list or tuple"
于 2018-05-15T14:00:44.827 回答
2

安装版本 4.5.3 RC

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

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

于 2015-06-27T20:24:59.500 回答
1

它看起来像是 PyCharm 4.5 的新 manage.py 任务集成中的一个错误。请将此问题报告给PyCharm 的问题跟踪器

于 2015-05-22T21:43:20.163 回答
1

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

  1. 列表,而不是元组或集合。在用于选择选项的 django 命令中,我有时使用元组,有时使用列表。并且跑步者通常只与列表一起工作。如果您将使用任何其他结构进行选择,您将收到错误消息。你可以在your_pycharm_dir/helpers/pycharm/django_manage_command_provider/_parse/_utils.py string 26中看到这个assert isinstance(opt.choices, list), "Choices should be list"
  2. 命令 args 必须是字符串。如果你在命令中有这样的东西, 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

于 2015-05-26T15:58:05.297 回答