“No module named manage” in PyCharm

2019-07-21 09:14发布

I have a problem with PyCharm. When I click on "Run Django console" or "Run manage.py task" in "Tools" I get:

Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File "/home/vagrant/.pycharm_helpers/pycharm/django_manage_shell.py", line 46, in run
    run_module(manage_file, None, '__main__', True)
  File "/opt/python3.3/lib/python3.3/runpy.py", line 168, in run_module
    mod_name, loader, code, fname = _get_module_details(mod_name)
  File "/opt/python3.3/lib/python3.3/runpy.py", line 104, in _get_module_details
    raise ImportError("No module named %s" % mod_name)
ImportError: No module named manage

My project and virtualenv is located on the virtual machine in vagrant. In PyCharm I customized ssh-connection and python interpreter to vagrant . I see actual dependencies of my virtualenv in the "Settings" -> "Python Interpeter".

When I click on "Run Django console" I see command:

vagrant:///home/username/vagrant/vm/home/vagrant/venv/mezza3.3/bin/python3.3 -u /home/vagrant/.pycharm_helpers/pydev/pydevconsole.py 0 0. 

It is working through my host terminal.

Now, I'm using "Start SSH session" in "Tools" to connect to the guest django shell. But I want to use the main feature.

How can I fix this? Thanks!

Environment: PyCharm 3.4.1; django 1.6.5; python 3.3; host\guest os is ubuntu 12.04.

Hard fix:

1) go to /home/vagrant/.pycharm_helpers/pycharm/;

2) open django_manage_shell.py;

3) look for method run(working_dir);

4) insert strings below method

if os.getenv('PYCHARM_WORKING_DIRECTORY'):
    working_dir = os.getenv('PYCHARM_WORKING_DIRECTORY')

5) save file;

6) go to "File" -> "Settings" -> "Console" -> "Django Console...";

7) add "Environment variables":

PYCHARM_WORKING_DIRECTORY = <path_to_guest_root_project_folder>.

0条回答
登录 后发表回答