1

This question sounds similar to this one, but it is different. When I press F5 to run my script in Spyder, the console shows a line like this:

runfile('C:/Users/usr/Documents/Python Scripts/BanditBook/algorithms/ucb/test_ucb1.py'
, wdir='C:/Users/usr/Documents/Python Scripts/BanditBook/algorithms/ucb')

I want to change that wdir argument to go up two levels so that I am automatically running the script wdir = C:/Users/usr/Documents/Python Scripts/BanditBook. How can I do this in Spyder? I am running Python 2.7.

Community
  • 1
  • 1
Moderat
  • 1,462
  • 4
  • 17
  • 21

1 Answers1

6

Press CTRL+SHIFT+ALT+P then you can go to the 'Run' tab. Then under 'Working directory' select the 'the following directory' box. Type in:

C:/Users/usr/Documents/Python Scripts/BanditBook 

Click Apply and OK and it should run from that location. If you want it back to the way it was for other scripts simply change it back to 'the script directory' and you should be good to go!

If you want to change the wdir every time, I would suggest checking the Always show Run Settings dialog on a first file run on the run tab so it pops up when you need it.

Hope this helps!

jezrael
  • 822,522
  • 95
  • 1,334
  • 1,252
Alex
  • 1,064
  • 1
  • 11
  • 16