Setting current directory for Interactive Console in pydev (Eclipse) at console startup
Asked Answered
I

1

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

Iffy answered 25/4, 2012 at 16:35 Comment(0)
E
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?

Enschede answered 26/4, 2012 at 11:52 Comment(3)
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]Iffy
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?Enschede
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 :|Iffy

© 2022 - 2024 — McMap. All rights reserved.