mjp
mjp

Reputation: 1689

Spyder changes working directory (wdir) when running a script

When running a certain script, Spyder always changes the working directory (wdir) away from the set global working directory.

I recently migrated my data to a new_user and Spyder works fine except for one script which always changes the wdir to the old_user home directory when running the code.

In [1]: runfile('/home/new_user/SPYDER/test.py', wdir='/home/old_user/SPYDER')

I had already checked:

Upvotes: 2

Views: 7572

Answers (1)

mjp
mjp

Reputation: 1689

The issue turned out to be the run settings:

Preferences -> Run -> General Settings -> Default Working Directory

This was still set to the old_user home directory, and not the new user. I don't know why this didn't affect other scripts (or why it was still set to the old user) but, when this was changed to new_user, it worked fine and ran with the correct wdir.

Upvotes: 3

Related Questions