Forums

Changing my working directory manually?

Hello,

PA says my Source Code is /home/eabsenteeproject/eAbsentee and my working directory is /home/eabsenteeproject/eAbsentee - how do I change my working directory to /home/eabsenteeproject/?

Being unable to set it to that is causing me all sorts of import errors when my site loads (which I asked a question about earlier, and still don't know why). Please help!

Imports are not based on the working directory. They are based on the Python path in sys.path, which is usually set in your web app's WSGI file. You can edit it there.

The question was "how to change the working directory" and not "how can i avoid import errors". The answer has relevance to the users problem but not to his question ;-)

Fair point! It is the answer to the actual problem they're having, but not to their specific question. The answer to the specific question of how to change the working directory on the "Web" page is "click on it and you can edit it" :-)

Hi, I have a question about Glenn's post from July 20. I need to change my working directory and want to understand if any hidden changes would result. If my sys.path in my wsgi.py file and my working directory differ, do both end up in my PYTHONPATH?

My working directory is

/home/username/app_root/modules_folder

And my wsgi.py file contains

path = os.path.expanduser('/home/username/app_root')
if path not in sys.path:
    sys.path.append(path)

My PYTHONPATH should be app_root/modules_folder, but I incorrectly set it to app_root in my wsgi.py file. And my working directory should be app_root, but I set it to app_root/modules_folder. However, I'm having no issue importing my modules that live in modules_folder, and I think that's because my working directory gets added to my PYTHONPATH.

Basically, I incorrectly switched my working directory and sys.path but my error somehow didn't result in failure, and trying to understand why.

You can just add logging to your web app that would print the content of the variables you are interested in and check it.