2

I want to start an interactive console in pydev from project directory, in order to import an app. I tried to use os.chdir at startup from Window->Preferences->PyDev->Interactive Console->Initial interpreter commands. I read https://docs.djangoproject.com/en/dev/ref/settings/ searching for an entry to set path but I didn't find anything. Thanks

Edit: I had to import module first in order to import app

gc5
  • 9,468
  • 24
  • 90
  • 151

1 Answers1

2

Strange, I must say that after changing the initial interpreter commands to be:

import sys; print('%s %s' % (sys.executable or sys.platform, sys.version))
import os;os.chdir('c:\\')

Later doing (in the shell):

import os.path
os.path.abspath('.')

Does show the expected path... Aren't you getting that? What do you get when you do the abspath('.') in the shell after the startup?

Fabio Zadrozny
  • 24,814
  • 4
  • 66
  • 78
  • this solution works but it is not what I need (I'm editing my question): I need to import some module, with PyDev PYTHON_PATH is set automatically in order to see my project folder, but when in the interactive console I try to import some modules from the project folder I get an exception and I cannot import them. I want to change sys.path[0] – gc5 Apr 26 '12 at 12:12
  • Actually, if you configured the source folders properly within PyDev, the PYTHONPATH should be correct already when you do the launch... Can you post a screenshot of the PyDev package explorer and what you're importing which doesn't work? – Fabio Zadrozny Apr 26 '12 at 12:32
  • You're right. I couldn't import an app but I had to import its module first. I thought I could import the app directly without importing its module. Sorry for your time :| – gc5 Apr 26 '12 at 12:53