Skip to content

Windows Issues #20

Closed
youngpm opened this Issue Jan 25, 2012 · 28 comments
@youngpm
youngpm commented Jan 25, 2012

Hi,

I've been trying to get GVIM and IPython to play together, without success so far on Windows 7.

Here are the steps I've taken:

  1. I launch IPython qtconsole successfully. I'm using version 0.12, what came with the EPD Python 2.7.2.
  2. :echo has('python') returns 1 for me.
  3. I source ipy.vim successfully in vim.

Things go bad for me when I attempt to run ":IPython" in vim.

I get a "Runtime Error!" alert about "R6034, An application has made an attempt to load the C runtime library incorrectly."

VIM reports the following:

Traceback (most recent call last):
File "", line 1, in
File "", line 39, in km_from_string
File "C:\Python27\lib\site-packages\IPython\zmq__init__.py", line 39, in
check_for_zmq('2.1.4')
File "C:\Python27\lib\site-packages\IPython\zmq__init__.py", line 17, in check_for_zmq
import zmq
File "C:\Python27\lib\site-packages\zmq__init__.py", line 32, in
ctypes.cdll.LoadLibrary(libzmq)
File "C:\Python27\Lib\ctypes__init__.py", line 431, in LoadLibrary
return self.dlltype(name)
File "C:\Python27\Lib\ctypes__init_
.py", line 353, in init
self._handle = _dlopen(self._name, mode)

Any idea what my issue is? From IPython i can import ctypes and zmq. I'm pretty new to Python and IPython, which is probably the biggest problem!

Thanks for any help!
-Patrick

@ivanov
Owner
@youngpm
youngpm commented Jan 25, 2012

I think I found the problem, I am pretty sure the version of vim I have was not compiled with the +python libraries. I faked myself out by adding the python.vim to the plugin directory, which is why it was returning 1! Now to get a version compiled with python!

I'll let you know if I get it going.

Thanks!

@unpingco
@youngpm
youngpm commented Jan 25, 2012

Well I reinstalled gvim, and the python libraries are there this time! Not sure that the issue was the first go around. In any case, :include shows +python. This is gvim 7.3.46, which is supposedly compiled with Python 2.7, the flavor I'm using.

Checking

$ vim -c ':py import os; print os.file' -c ':q'
$ python -c 'import os; print os.file'

Vim says C:\Python27\Lib\os.pyc
Python says C:\Python27\lib\os.pyc

The case shouldn't matter on Windows right? The actual folder is Lib.

I get the same error,


Traceback (most recent call last):
File "<string>", line 1, in <module>
File "<string>", line 39, in km_from_string
File "C:\Python27\lib\site-packages\IPython\zmq\__init__.py", line 39, in <module>
check_for_zmq('2.1.4')
File "C:\Python27\lib\site-packages\IPython\zmq\__init__.py", line 17, in check_for_zmq
import zmq
File "C:\Python27\lib\site-packages\zmq\__init__.py", line 32, in <module>
ctypes.cdll.LoadLibrary(libzmq)
File "C:\Python27\Lib\ctypes\__init__.py", line 431, in LoadLibrary
return self._dlltype(name)
File "C:\Python27\Lib\ctypes\__init__.py", line 353, in __init__
self._handle = _dlopen(self._name, mode)

The same as before! Any more thoughts?

Thanks!

@unpingco
@youngpm
youngpm commented Jan 25, 2012

Yeah, here is some output:

`

import zmq
zmq.zmq_version()
'2.1.11'
`

Importing ctypes also returns no errors. It is version 1.1.0.

@unpingco
@ivanov
Owner
ivanov commented Jan 27, 2012

@youngpm: you can also take a look at #21 to see if you're running into a similar issue, and if the solution proposed in this pyodbc bug solves it for you

@youngpm
youngpm commented Feb 6, 2012

Sorry I've been out of the office on jury duty! In any case, I'm going to try what you suggest. edouardp says

"I did this with all of the *.pyd files and now I've got gvim <-> ipython 0.12 interaction going great!"

It is unclear to me which *.pyd files he is referring to.

Thanks!

@tmdk
tmdk commented Feb 15, 2012

I think he is referring to all the *.pyd files in the pyzmq package:

zmq\core\constants.pyd
zmq\core\context.pyd
zmq\core\device.pyd
zmq\core\error.pyd
zmq\core\message.pyd
zmq\core\poll.pyd
zmq\core\socket.pyd
zmq\core\stopwatch.pyd
zmq\core\version.pyd
zmq\devices\monitoredqueue.pyd
zmq\utils\initthreads.pyd
zmq\utils\rebuffer.pyd

I had the same problem as in #21 and applying the fix referred by edouardp to these files fixed it for me!

HTH

@quasarj
quasarj commented May 30, 2012

I still get the error the first time I type :IPython, but everything seems to function right after that, so I can confirm this still works!

@danbe
danbe commented Jun 17, 2012

Here are the commands I used to make it run and their outputs.
Windows xp, Python 2.7.1 (r271:86832, Nov 27 2010, 18:30:46) [MSC v.1500 32 bit (Intel)], zmq 2.2.0

Note that dependencywalker is missing ieshims.dll and wer.dll, but they don't seem to matter

C:\Python27\Lib\site-packages\pyzmq-2.2.0-py2.7-win32.egg\zmq\utils>dir

Directory of C:\Python27\Lib\site-packages\pyzmq-2.2.0-py2.7-win32.egg\zmq\utils

06/17/2012 09:06 AM

.
06/17/2012 09:06 AM ..
06/16/2012 02:39 PM 642 allocate.h
06/16/2012 02:39 PM 9,753 buffers.pxd
06/16/2012 02:39 PM 289 initthreads.py
06/16/2012 02:39 PM 618 initthreads.pyc
06/17/2012 09:02 AM 11,776 initthreads.pyd
06/16/2012 02:39 PM 2,407 jsonapi.py
06/16/2012 02:39 PM 2,492 jsonapi.pyc
06/12/2008 03:58 PM 739,376 mt.exe
06/16/2012 02:39 PM 1,324 pyversion_compat.h
06/16/2012 02:39 PM 286 rebuffer.py
06/16/2012 02:39 PM 609 rebuffer.pyc
06/17/2012 09:06 AM 25,600 rebuffer.pyd
06/16/2012 02:39 PM 980 strtypes.py
06/16/2012 02:39 PM 859 strtypes.pyc
06/16/2012 02:39 PM 3,514 zmq_compat.h
06/16/2012 02:39 PM 0 init.py
06/16/2012 02:39 PM 166 init.pyc

C:\Python27\Lib\site-packages\pyzmq-2.2.0-py2.7-win32.egg\zmq\utils>mt.exe -inputresource:c:\windows\system32\python27.dll;#2 -outputresource:initthreads.pyd;#2

Microsoft (R) Manifest Tool version 5.2.3790.2076
Copyright (c) Microsoft Corporation 2005.
All rights reserved.

C:\Python27\Lib\site-packages\pyzmq-2.2.0-py2.7-win32.egg\zmq\utils>mt.exe -inputresource:c:\windows\system32\python27.dll;#2 -outputresource:rebuffer.pyd;#2
Microsoft (R) Manifest Tool version 5.2.3790.2076
Copyright (c) Microsoft Corporation 2005.
All rights reserved.

C:\Python27\Lib\site-packages\pyzmq-2.2.0-py2.7-win32.egg\zmq\utils>cd. .

C:\Python27\Lib\site-packages\pyzmq-2.2.0-py2.7-win32.egg\zmq\utils>
C:\Python27\Lib\site-packages\pyzmq-2.2.0-py2.7-win32.egg\zmq\utils>mt.exe -inputresource:c:\windows\system32\python27.dll;#2 -outputresource:..\core\constants.
pyd;#2
Microsoft (R) Manifest Tool version 5.2.3790.2076
Copyright (c) Microsoft Corporation 2005.
All rights reserved.

C:\Python27\Lib\site-packages\pyzmq-2.2.0-py2.7-win32.egg\zmq\utils>mt.exe -inputresource:c:\windows\system32\python27.dll;#2 -outputresource:..\core\context.py
d;#2
Microsoft (R) Manifest Tool version 5.2.3790.2076
Copyright (c) Microsoft Corporation 2005.
All rights reserved.

C:\Python27\Lib\site-packages\pyzmq-2.2.0-py2.7-win32.egg\zmq\utils>mt.exe -inputresource:c:\windows\system32\python27.dll;#2 -outputresource:..\core\device.pyd
;#2
Microsoft (R) Manifest Tool version 5.2.3790.2076
Copyright (c) Microsoft Corporation 2005.
All rights reserved.

C:\Python27\Lib\site-packages\pyzmq-2.2.0-py2.7-win32.egg\zmq\utils>mt.exe -inputresource:c:\windows\system32\python27.dll;#2 -outputresource:..\core\error.pyd;
#2
Microsoft (R) Manifest Tool version 5.2.3790.2076
Copyright (c) Microsoft Corporation 2005.
All rights reserved.

C:\Python27\Lib\site-packages\pyzmq-2.2.0-py2.7-win32.egg\zmq\utils>mt.exe -inputresource:c:\windows\system32\python27.dll;#2 -outputresource:..\core\message.py
d;#2
Microsoft (R) Manifest Tool version 5.2.3790.2076
Copyright (c) Microsoft Corporation 2005.
All rights reserved.

C:\Python27\Lib\site-packages\pyzmq-2.2.0-py2.7-win32.egg\zmq\utils>mt.exe -inputresource:c:\windows\system32\python27.dll;#2 -outputresource:..\core\stopwatch.
pyd;#2
Microsoft (R) Manifest Tool version 5.2.3790.2076
Copyright (c) Microsoft Corporation 2005.
All rights reserved.

C:\Python27\Lib\site-packages\pyzmq-2.2.0-py2.7-win32.egg\zmq\utils>mt.exe -inputresource:c:\windows\system32\python27.dll;#2 -outputresource:..\core\socket.pyd
;#2
Microsoft (R) Manifest Tool version 5.2.3790.2076
Copyright (c) Microsoft Corporation 2005.
All rights reserved.

C:\Python27\Lib\site-packages\pyzmq-2.2.0-py2.7-win32.egg\zmq\utils>mt.exe -inputresource:c:\windows\system32\python27.dll;#2 -outputresource:..\core_poll.pyd;
#2
Microsoft (R) Manifest Tool version 5.2.3790.2076
Copyright (c) Microsoft Corporation 2005.
All rights reserved.

C:\Python27\Lib\site-packages\pyzmq-2.2.0-py2.7-win32.egg\zmq\utils>mt.exe -inputresource:c:\windows\system32\python27.dll;#2 -outputresource:..\core_version.p
yd;#2
Microsoft (R) Manifest Tool version 5.2.3790.2076
Copyright (c) Microsoft Corporation 2005.
All rights reserved.

C:\Python27\Lib\site-packages\pyzmq-2.2.0-py2.7-win32.egg\zmq\utils>mt.exe -inputresource:c:\windows\system32\python27.dll;#2 -outputresource:..\devices\monitor
edqueue.pyd;#2
Microsoft (R) Manifest Tool version 5.2.3790.2076
Copyright (c) Microsoft Corporation 2005.
All rights reserved.

@johndgiese

I have been trying to get this to work for a few days now; I am having the exact same problems.

A pop-up says:

Runtime Error!
Program: C:\opt\vim\vim73\gvim.exe

R6034
An application has made an attempt to load the C runtime library incorrectly.
Please contact the application's support team for more information.

I check the versions of python in vim, and it is correct. I also checked that the python_path is the same. I am trying to follow the instructions in here, but haven't gotten it to work yet.

I am on windows 64bit,
Python 2.7.3
newest version of vim (7.3. something)
IPython 0.12

@danbe
danbe commented Jun 21, 2012

I never got a popup, just an import error, pyzmq version not ok, import error, initthreads import error etc. Maybe you have a different error,
Did you run the dependencywalker on the dlls to see if anything is missing, and then try to fix the manifest with mt?
It works very nicely for me now.

@quasarj
quasarj commented Jun 21, 2012

I was getting the exact behavior johndgiese is seeing - with the popup error. Running mt as explained above on all of the pyd files fixed it for me. Note that some of my files didn't match the exact ones from the pydoc thread, i had to run it on ALL the pyd files in the pyzmq directory.

@shelper
shelper commented Jul 26, 2012

after i run all the mt commands, the pop up window is still there with error R6034 and zmq import error in vim output when i put :IPython first time, but when i put second time, then it seems the vim is communicating with ipython but ipython does not fire output, say, i run :py run_command('a=1234') and there is nothing happend in ipython, but when i type print a in ipython console, the a is 1234.
run enviroment: python 2.7.2, ipython 0.12.1, any one has any idea?

@johndgiese

When you run a command in vim-ipython it sends the command to the ipython server; this is a separate process than the python that vim has internally for scripting; the namespaces are completely separate. Running :py commands will always run in vim's python process, while writing commands in the ipython console will send the command via zmq to the ipython process you started yourself, it will then execute the command, and send the output back to vim via zmq, at which point vim will update the vim-ipython prompt.

@shelper
shelper commented Jul 26, 2012

thanks for explaining, after reading your comments several times, i think i got some idea, so, here is the problem i encounter:
1 start ipython qtconsole
2. start gvim, open foo.py file (which only has lines: 'a= 1234; print a')
3 run :IPython in vim, window pop up giving runtime library loading error R6034,
4. run :IPython again in vim, no error shows up
5. press F5 in vim, the minibuffer shows:
In[1]: In[]: run -i 'Path\to\foo.py'
press enter or type command to continue
6. switch to ipython qtconsole,found no output, but type a, it prints 1234, which means a is there with value from foo.py

So, i know vim and ipython are talking to each other, but this is not so useful if i can not get output from ipython.. and also the error R 6034 shows the first time ? actually if i skip step 4 above, the phenomena is the same...
i just wonder if there is a solution to this...

thanks again!

P.S. in step 5, the number '1' in the 'In[1]' matches the prompt in ipython, that means if you run several command in ipython qtconsole, and then run a script in vim by F5, the number will change to current ipython input prompt number

@johndgiese

This is a bit complicated, but basically there is an ipython kernel, and the console (and vim) are clients that talk to the kernel. Currently the output resulting from commands from one client (e.g. vim) are not displayed in other clients (the IPython kernel).

I actually have my own version of vim-ipython that I have heavily modified from ivanov's. If you want to give it a try you can. I am setting up a repository for you, in case you want to.

@shelper
shelper commented Jul 26, 2012

i actually saw the same issue here: ipython/ipython#1873
did you really solve the problem? that would be nice and greatly appreciated if you can share your script,
i am working on windows 7 btw,
thx

@johndgiese
@shelper
@johndgiese
@LeszekSwirski

I still get the R6034 error, even after running the above mt script, but this time not on zmq but IPython itself, e.g. when running

:py import IPython
@LeszekSwirski

Turns out I was having issues with import uuid. I've now fixed this by merging my python manifest into my vim/gvim's manifest, like so:

mt -inputresource:C:\windows\syswow64\python27.dll;#2 -out:%TEMP%\python.manifest
mt -inputresource:"C:\Program Files (x86)\vim\vim73\gvim.exe" -out:%TEMP%\gvim.manifest
mt -manifest %TEMP%\python.manifest %TEMP%\gvim.manifest -outputresource:"C:\Program Files (x86)\vim\vim73\gvim.exe"
mt -manifest %TEMP%\python.manifest -outputresource:"C:\Program Files (x86)\vim\vim73\vim.exe"

(The above is from memory, make sure to backup your vim/gvim first)

@vakosel
vakosel commented Dec 8, 2012

Hi all, i had exactly the same issues . My environment is win7 , python27 , pyzmq 2.2.0.1 , ipython 13.1 .Gvim 7.3.754 build with gcc 4.6.2 and python27

I resolved them following these steps after testing with Dep.Walker that there were errors with MSVCR90.DLL loading
when opened *.PYD and *.DLL (1) files from pyzmq foder.
1) went to the folder pyzmq with VS command line tools 2012 x86 (my os) and searched for all pyd files.
2) i went to every subfolder where these .pyd existed and executed:

mt.exe -inputresource:c:\windows\system32\python27.dll;#2 -outputresource:(XXX).pyd;#2
where (XXX) was every pyd (around 10) in every subfolder..The console didn't show any mistake in the procedure
3) i did the same with the .dll file AND VOILA!

Everything is working like charm! I must confess that DANBE'S POST above was the real key ...

I just wanted to post this in order to assure that this works.. :+1:

@ivanov
Owner
ivanov commented Mar 26, 2013

closing this issue

@ivanov ivanov closed this Mar 26, 2013
@accuya
accuya commented Apr 27, 2014

I came across this problem yesterday. XP + python27 + vim7.3 (+python)
I fixed it by executing mt.exe -inputresource:"d:\Python27\python.exe" -outputresource:"d:\Program Files\Vim\vim73\gvim.exe"
This command actually replaced the manifest embedded in gvim.exe with the one in python.exe.
But it DO fix the R6034 error when executing IPython command in gvim.
Hope this helps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.