Changing working directory in Spyder console

2,106 views
Skip to first unread message

Ryan Villamil

unread,
Jan 19, 2014, 1:09:07 PM1/19/14
to spyd...@googlegroups.com
I am using Spyder 2.2.4 on Win7 64. I am having trouble using some of the embedded command line operations (!command) in the basic Spyder console. Specifically !cd, I can traverse around c: drive fine, but a command like "!cd D:\", fails with a syntax error (EOL while scanning string). 

What is the correct way to use command like !cd, I notice this happens for other command line calls as well. What rules are broken when I do "!cd D:\", vs "!cd d:\foo" (which works)? What is the difference between %cd and !cd? Should I be using %commands instead? 

Can't seem to find much documentation on using command line operations in a Spyder console.

Thx 

Adrian Klaver

unread,
Jan 19, 2014, 4:22:18 PM1/19/14
to spyd...@googlegroups.com
On 01/19/2014 10:09 AM, Ryan Villamil wrote:
> I am using Spyder 2.2.4 on Win7 64. I am having trouble using some of
> the embedded command line operations (!command) in the basic Spyder
> console. Specifically !cd, I can traverse around c: drive fine, but a
> command like "!cd D:\", fails with a syntax error (EOL while scanning
> string).

Well I am going to say the answer is found here:

http://ipython.org/ipython-doc/stable/api/generated/IPython.core.magics.osm.html?highlight=cd#IPython.core.magics.osm.OSMagics.cd

"Note that !cd doesn’t work for this purpose because the shell where
!command runs is immediately discarded after executing ‘command’"

>
> What is the correct way to use command like !cd, I notice this happens
> for other command line calls as well. What rules are broken when I do
> "!cd D:\", vs "!cd d:\foo" (which works)? What is the difference between
> %cd and !cd? Should I be using %commands instead?

In !cd the ! runs the command following in the system shell. %cd is a
built in command.

In the link above see bang and cd for more information.

>
> Can't seem to find much documentation on using command line operations
> in a Spyder console.
>
> Thx
>
> --



--
Adrian Klaver
adrian...@gmail.com
Reply all
Reply to author
Forward
0 new messages