Pycharm cant open manage.py task
Asked Answered
R

4

7

In one of my projects , I cannot open manage task console. It works for other projects but not for this one. It worked before, but it stopped recently. I tried using old versions of the project, but its still broken. I get this error:

    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'
Russia answered 22/5, 2015 at 18:44 Comment(2)
from memory you need to set the path to manage.py in pycharm - look for the 'Edit Configuration' menu in the toolbar and look for the 'django' settings sectionEnlargement
i have the path set up, so that should not be it. but how do you do that exactly, incase i might have missed something?Russia
N
2

Install version 4.5.3 RC

If you are using a virtual environment, make sure your project interpreter (settings > Project:... > Project Interpreter) points to the python executable in it (e.g., my_virtual_env/bin/python3.4).

If you are using a virtual machine, you also need to have your project interpreter setting point to the python version under your virtual environment under your virtual machine. If you are using Vagrant this is easy, as when you try to add a new interpreter PyCharm lets you select Vagrant, and then browse the VM file system to point to the file you needed.

Nucellus answered 27/6, 2015 at 20:24 Comment(0)
R
3

update your _utils.py in YOUR_PYCHARM_INSTALLATION_DIR\helpers\pycharm\django_manage_commands_provider\_parser\_utils.py

and changes the code in line 20:

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

with

assert isinstance(opt.choices, (list, tuple)), "Choices should be list or tuple"
Runty answered 15/5, 2018 at 14:0 Comment(0)
N
2

Install version 4.5.3 RC

If you are using a virtual environment, make sure your project interpreter (settings > Project:... > Project Interpreter) points to the python executable in it (e.g., my_virtual_env/bin/python3.4).

If you are using a virtual machine, you also need to have your project interpreter setting point to the python version under your virtual environment under your virtual machine. If you are using Vagrant this is easy, as when you try to add a new interpreter PyCharm lets you select Vagrant, and then browse the VM file system to point to the file you needed.

Nucellus answered 27/6, 2015 at 20:24 Comment(0)
S
1

It looks like a bug in the new manage.py tasks integration of PyCharm 4.5. Please report this issue to the PyCharm's issue tracker.

Seko answered 22/5, 2015 at 21:43 Comment(1)
I created a ticket, if someone has the same problem: JetBrains TicketRussia
A
1

I faced with the same problem today. After debugging pycharm django command runner I found out some problems. So the problems in my project were:

  1. List, not tuples or sets. In my django commands for choices options I sometimes use tuples, sometimes lists. And runner works normally only with lists. If you will use any other sturcture for choices you will get an error. You can see this in your_pycharm_dir/helpers/pycharm/django_manage_command_provider/_parse/_utils.py string 26 assert isinstance(opt.choices, list), "Choices should be list"
  2. Command args must be a string. If you have something like this in command class Command(BaseCommand): args= ['app_label', 'model_name', ] you will get an error. Args must be strings

If you want debug pycharm django manage.py task runner you can start at your_pycharm_dir/helpers/pycharm/manage_py_task_provider.py. And wrap parser at string 22 in try except try: dumper = _xml.XmlDumper() parser.report_data(dumper) print(dumper.xml) except Exception: pass

Auvil answered 26/5, 2015 at 15:58 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.