Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change drive in IPython under windows

How can I change drive letter while in IPython under windows? For example, !cd W: does not make W: the current path, it just changes the path if you would change to drive W. Changing to a dos shell with !cmd and then changing to W: does not have any effect to the IPython shell.

like image 764
MKesper Avatar asked Oct 22 '25 15:10

MKesper


2 Answers

From the cd ? command:

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

So, just use the cd, and make sure to quote path so the colon after the drive letter isn't misinterpreted.

cd 'W:'
like image 137
Shaun Lebron Avatar answered Oct 25 '25 16:10

Shaun Lebron


I have a Win 10 machine with Anaconda 2020.11 python installed, out of the box no updates. ipython 7.19.0. The only way I can cd to somewhere on another drive letter is

cd d:/

No other permutation works: cd d:, cd d:, cd d:\, cd 'd:', cd 'd:', etc.

So there's an answer but it's quite annoying to figure out.

like image 20
D Strozzi Avatar answered Oct 25 '25 17:10

D Strozzi