Visual Studio 2017 Anaconda Prompt Fix

For some reason, if you install the Python Tools for Visual Studio 2017, you’ll end up with an Anaconda command prompt that won’t work. It apparently is due to a path length limitation where the total target path exceeds some ridiculously small number in Windows for a shortcut.

Thankfully, the fix isn’t painful — it’s just frustrating that it needs to be done.

I’ve seen suggestions to use the old-school DOS 8.3 file paths, but I prefer to use something that still reads well and maps to other dev command line tools on my workstation.

I created a directory junction in an existing folder C:\Dev:

mklink /d c:\Dev\Anaconda3_64 "c:\Program Files (x86)\Microsoft Visual Studio\Shared\Anaconda3_64"

Specifically, I created:

C:\Dev\Anaconda3_64

which is a junction to:

c:\Program Files (x86)\Microsoft Visual Studio\Shared\Anaconda3_64

You can use any junction directory you want, but remember that it can’t be too long, or you’ll have the same problem with a different name/path. :) When using mklink, be sure to quote the path for the Anaconda install in the Visual Studio directory as shown above in the mklink example.

Next, I updated the command prompt with the new path:

c:\Dev\Anaconda3_64\pythonw.exe C:\Dev\Anaconda3_64\cwp.py C:\Dev\Anaconda3_64 %windir%\system32\cmd.exe /k c:\Dev\Anaconda3_64\Scripts\activate.bat c:\Dev\Anaconda3_64

Of course, you’ll need to substitute the path you used (just copy and paste into Notepad and do a quick search and replace with the full path I used).

It should start up without issue now.