Gvim For Vim-Windows cannot complete wxpython.

Source: Internet
Author: User
Tags win32 error

Turn: http://www.cnblogs.com/cbscan/archive/2012/02/26/2368875.html

This problem has been solved for a long time.


First, directly import wx In the python interpreter. If wxpython can be used properly, it indicates that wxpython has been installed successfully.

However, open gvim, edit a. py file, import wx in the script, declare a variable APP = wx. app (), and then type app.. The Automatic completion menu is not displayed.

You must know that the object-oriented GUI library is very large and is unlikely to be used to record class methods. Therefore, it is very important to automatically complete the list provided.


Gvim supports Python auto-completion in the file pythoncomplete. in vim, you can see that the complementing function depends on the reflection of dynamic languages (eval and Dir). If this function is faulty, call the python function showdbg to investigate it.

OK. In the gvim command bar, type:

: Py showdbg ()

According to the information, the python interpreter built in gvim fails to import wx.

Test in gvim:

: Py import WX

The module cannot be found when the prompt "Import _ core _" is displayed.


Append ollydbg to gvim and find that python uses LoadLibraryEx (load_with_altered_search_path) to load _ core _. PYD. The result fails and the Win32 error code is error_mod_not_found. Write a C ++ test program by yourself (the VC version used should be the same as the VC version compiled for wxpython), and call LoadLibraryEx with the same parameters, but the program can be successful.


In short, here, it is confirmed that gvim cannot be automatically supplemented because gvim's built-in Python interpreter import wx fails, while the latter fails to import wx because Windows uses LoadLibraryEx to load _ core _. PYD fails.


Observe the dependency items of the dynamic library _ core _. PYD. The main missing items are msvcr90.dll and msvcp90.dll (I used vc2008 to compile wxpython ). Copy these two files to _ core _. in the directory where PYD is located, type py import wx in the gvim command line, and an error is still reported. However, the Windows message box is displayed this time, "An application has made an attempt to load the C Runtime Library without using a manifest ".


Open _ core _. in the PYD file, search for the keyword "Manifest" and see the embedded manifest. windows. "Common-Controls", compared with other manifest files generated during wxpython compilation, the "Microsoft. vc90.crt, copy a manifest file (such as wxmsw28uh_adv_vc.dll.manifest) from the Lib \ vc_dll directory of my wxpython, and use the MT tool to embed _ core _. in PYD:

MT-nologo-manifest wxmsw28uh_adv_vc.dll.manifest-outputresource: _ core _. PYD; 2

Another test showed that there was a problem with the embedded manifest of all PYD files. Use the following command to update each PYD file in sequence.


To sum up, I used gvim in Windows to write Python code. When I accessed the wxpython library, the auto-completion function provided by gvim failed because it was output by the compilation script provided by wxpython *. the PYD file is embedded with the wrong manifest. The solution is to find a complete manifest generated during wxpython compilation and embed it all in sequence *. PYD file.


For reference, the content of my embedded manifest file (of course, it is related to the VC version I use ):

<?xml version='1.0' encoding='UTF-8' standalone='yes'?><assembly xmlns='urn:schemas-microsoft-com:asm.v1' manifestVersion='1.0'>  <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">    <security>      <requestedPrivileges>        <requestedExecutionLevel level='asInvoker' uiAccess='false' />      </requestedPrivileges>    </security>  </trustInfo>  <dependency>    <dependentAssembly>      <assemblyIdentity type='win32' name='Microsoft.VC90.CRT' version='9.0.21022.8' processorArchitecture='x86' publicKeyToken='1fc8b3b9a1e18e3b' />    </dependentAssembly>  </dependency>  <dependency>    <dependentAssembly>      <assemblyIdentity type='win32'              name='Microsoft.Windows.Common-Controls'        version=''                               processorArchitecture='x86'                   publicKeyToken='6595b64144ccf1df'               language='*' />    </dependentAssembly>  </dependency></assembly>
Copy code


In addition, the reason why the python interpreter and other Python container programs can successfully import wx, it is because they have loaded the correct version of CRT before import WX (for example, the python interpreter is compiled by vc2008), while gvim is compiled by C language, the C ++ library is loaded for the first time only when import WX-> Import _ core _ is used. The incomplete embedded manifest will cause an error.


Although it is a wxpython bug, it must be said that Microsoft 2.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.