ImportError: No module named pydevd

I am hoping someone can give me a clue on this. I can debug normal python programs but when I try to use the debugger with my Django app, it starts up and then I get the ImportError. Below is everything I get in the console:

runnerw.exe C:\Python27\python.exe "C:\Program Files\JetBrains\PyCharm 2.5\helpers\pydev\pydevd.py" --multiproc --client 127.0.0.1 --port 1196 --file manage.py runserver 8000
Connected to pydev debugger (build 117.200)
pydev debugger: process 964 is connecting
pydev debugger: process 5496 is connecting
Validating models...

0 errors found
Django version 1.4, using settings 'myapp.site.settings'
Development server is running at http://127.0.0.1:8000/
Quit the server with CTRL-BREAK.
INFO 2012-05-02 11:28:53,043 mybackgroundthread 5496 5416 mybackgroundthread started.
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ImportError: No module named pydevd

This was working in PyCharm 2.0.2 with Django 1.3 but I recently upgraded to PyCharm 2.5 and Django 1.4. I am not sure if that is the root cause of the problem. I don't need the debugger often (but when I need it, I need it to work) so I think this is the first time I have tried it since the upgrade. It would be painful to rollback to a prior version of either one right now as I am in a time crunch.

评论操作 固定链接

Please try running the Django development server with the "No reload" option enabled.

0
评论操作 固定链接

No change with --noreload.

0
评论操作 固定链接

Could you please attach console output when you run Django server run configuration with 'No reload' checkbox enabled?

0
评论操作 固定链接

Ah ha!  I didn't see the checkbox, I just put --noreload in the Additional Options field.

Checking the box does the trick, the debugger seems to be working -- stops and breakpoints, lets me step through code, etc.

Here is the console output in case you just want to see it:

runnerw.exe C:\Python27\python.exe "C:\Program Files\JetBrains\PyCharm 2.5\helpers\pydev\pydevd.py" --client 127.0.0.1 --port 2347 --file manage.py runserver --noreload 8000
Connected to pydev debugger (build 117.200)
pydev debugger: starting
Validating models...

0 errors found
Django version 1.4, using settings 'pegasus.site.settings'
Development server is running at http://127.0.0.1:8000/
Quit the server with CTRL-BREAK.

Thanks!

0
评论操作 固定链接

Ok. Could you please also print out your PYTHONPATH?

Normally debugger should work in reload mode also, but in your case debugger run-time can't be imported from new django process for some reason.

Also can you please set environment variable PYCHARM_DEBUG=True and run django server without no-reload checkbox and paste console output here.

0
评论操作 固定链接

I have a similar error after updating to 2.5.1, build #PY-117.376 (running on OSX 10.6.8).  It's as if my src folder is not being added to my syspath.  (My colleague also had the same issue on Windows after updating to 2.5.1)

It happens when I start my django project, when the project tries to load a module in my models.py.

If I remove everything from models.py and just print PYTHONPATH, all I see is: /Applications/Dev/PyCharm.app/helpers

It works if I add my src folder to the paths under preferences in Project Interpreters -> Python Interpreters, but I have multiple branches checked out as different projects, and I don't want to create a different interpreter for each one.

Here is the full error message when I start the django server:

/Library/Frameworks/Python.framework/Versions/2.7/bin/python manage.py runserver --noreload 8000

Validating models...

Traceback (most recent call last):

  File "manage.py", line 12, in <module>

    execute_manager(settings)

  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Django-1.4-py2.7.egg/django/core/management/__init__.py", line 459, in execute_manager

    utility.execute()

  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Django-1.4-py2.7.egg/django/core/management/__init__.py", line 382, in execute

    self.fetch_command(subcommand).run_from_argv(self.argv)

  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Django-1.4-py2.7.egg/django/core/management/base.py", line 196, in run_from_argv

    self.execute(*args, **options.__dict__)

  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Django-1.4-py2.7.egg/django/core/management/base.py", line 232, in execute

    output = self.handle(*args, **options)

  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Django-1.4-py2.7.egg/django/core/management/commands/runserver.py", line 69, in handle

    self.run(*args, **options)

  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Django-1.4-py2.7.egg/django/core/management/commands/runserver.py", line 80, in run

    self.inner_run(*args, **options)

  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Django-1.4-py2.7.egg/django/core/management/commands/runserver.py", line 91, in inner_run

    self.validate(display_num_errors=True)

  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Django-1.4-py2.7.egg/django/core/management/base.py", line 266, in validate

    num_errors = get_validation_errors(s, app)

  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Django-1.4-py2.7.egg/django/core/management/validation.py", line 30, in get_validation_errors

    for (app_name, error) in get_app_errors().items():

  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Django-1.4-py2.7.egg/django/db/models/loading.py", line 158, in get_app_errors

    self._populate()

  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Django-1.4-py2.7.egg/django/db/models/loading.py", line 67, in _populate

    self.load_app(app_name)

  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Django-1.4-py2.7.egg/django/db/models/loading.py", line 88, in load_app

    models = import_module('.models', app_name)

  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Django-1.4-py2.7.egg/django/utils/importlib.py", line 35, in import_module

    __import__(name)

  File "/Users/me/Documents/dev/pycharm/testproject/src/testproject/../testproject/models.py", line 27, in <module>

    from testproject.testmodule import myTestFunction

ImportError: No module named testproject.testmodule

Process finished with exit code 1

0
评论操作 固定链接

Hi Adam,

could you please print sys.path?
Also make sure that directory containing manage.py (src/ folder in your case?) is selected in Settings->Django Support->Django Project Root

0

请先登录再写评论。