问题
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
回答1:
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?
来源:https://stackoverflow.com/questions/10319980/setting-current-directory-for-interactive-console-in-pydev-eclipse-at-console