2

So I do a lot of python work in GVim on Windows 7, and I'm running into an annoying roadblock. This might be more of a Windows question, but it's happening in Vim, so ...

I have this in my python.vim file to quickly run the current file in python:

nnoremap <silent> <F5> :!start cmd /c "python %:p" & pause<CR><CR>

and I'm working on a python script that calls ImageMagick via the shell. So, I hit F5, and I get an error that ImageMagick is "not recognized as an internal or external command".

However, when I run the python file from outside of GVim, it performs perfectly.

Eventually, I ran :!start cmd, and printed the Windows %PATH% from that command prompt. Much to my chagrin, the ImageMagick folder was not on my path. However, :echo $PATH from within vim has it, the path is correct in my System Properties -> Environment Variables, and any other command prompt has it.

[edit] Per request, these are the different paths:

Start cmd path (the bad one):

Path=C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Python27;C:\Program Files\Common Files\Autodesk Shared\;C:\Program Files (x86)\Common Files\Autodesk Shared\;C:\Program Files (x86)\Common Files\Softimage;C:\Program Files\Common Files\Softimage;C:\Program Files\Intel\DMIX;C:\PROGRA~2\ALPSER~1;C:\PROGRA~2\ALPSER~1\(x86);C:\Program Files (x86)\QuickTime\QTSystem\;C:\Program Files (x86)\WinMerge;c:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\;c:\Program Files\Microsoft SQL Server\100\Tools\Binn\;c:\Program Files\Microsoft SQL Server\100\DTS\Binn\;C:\Program Files\Microsoft Windows Performance Toolkit\;C:\Python27\Scripts;C:\Program Files\TortoiseSVN\bin;C:\Program Files (x86)\Windows Kits\8.1\Windows Performance Toolkit\;C:\Program Files\Microsoft SQL Server\110\Tools\Binn\;C:\Program Files (x86)\Microsoft SDKs\TypeScript\1.0\;C:\Program Files\Microsoft SQL Server\120\Tools\Binn\;C:\Program Files\doxygen\bin;C:\Program Files\Microsoft DNX\Dnvm\;C:\ProgramData\chocolatey\bin;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files (x86)\Graphviz2.38\bin;C:\Program Files\Git\cmd;C:\Program Files (x86)\Vim\vim74 

Regular path (the good one):

Path=C:\Program Files\ImageMagick-6.9.0-Q16;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Python27;C:\Program Files\Common Files\Autodesk Shared\;C:\Program Files (x86)\Common Files\Autodesk Shared\;C:\Program Files (x86)\Common Files\Softimage;C:\Program Files\Common Files\Softimage;C:\Program Files\Intel\DMIX;C:\PROGRA~2\ALPSER~1;C:\PROGRA~2\ALPSER~1\(x86);C:\Program Files (x86)\QuickTime\QTSystem\;C:\Program Files (x86)\WinMerge;c:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\;c:\Program Files\Microsoft SQL Server\100\Tools\Binn\;c:\Program Files\Microsoft SQL Server\100\DTS\Binn\;C:\Program Files\Microsoft Windows Performance Toolkit\;C:\Python27\Scripts;C:\Program Files (x86)\Autodesk\Backburner\;C:\Program Files\TortoiseSVN\bin;C:\Program Files (x86)\Windows Kits\8.1\Windows Performance Toolkit\;C:\Program Files\Microsoft SQL Server\110\Tools\Binn\;C:\Program Files (x86)\Microsoft SDKs\TypeScript\1.0\;C:\Program Files\Microsoft SQL Server\120\Tools\Binn\;C:\Program Files\doxygen\bin;C:\Program Files\Microsoft DNX\Dnvm\;C:\ProgramData\chocolatey\bin;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files (x86)\Graphviz2.38\bin;C:\Program Files\Git\cmd;C:\Program Files (x86)\CMake\bin;

Does anybody have an idea where this difference is coming from?

5
  • //not recognized as an internal or external command// When I run start cmd in gvim, i am not getting this error. Start cmd starts a cmd prompt. When I enter the command you specified, %:p is expanded as current filename and then command is executed.
    – SibiCoder
    May 26, 2016 at 3:56
  • Please include that in $PATH. You can also set it in .vimrc file like :set path+=/blah/blah/blah. After including, try once again.
    – SibiCoder
    May 26, 2016 at 4:00
  • @SibiCoder :!start cmd opens a command prompt, and it's the %path% in that command prompt that is missing ImageMagick. The path in vim is correct and is not reflected in the spawned cmd prompt. Adding the path to ImageMagic to the vim $path didn't work.
    – Tyler Fox
    May 26, 2016 at 18:13
  • Can you add the output of echo $PATH and %path% here?
    – SibiCoder
    May 27, 2016 at 3:37
  • I'm having this problem as well. Aug 28, 2018 at 2:04

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.