I'm trying to load a python extension to WinDBG, using PyKd.
.load pykd succeeds.
When I'm running !py, I get this:
failed to find python interpreter
Things I've tried:
Different versions of python
Using PyKd's dll and pyd files
.reload /f
Different symbol paths
Debugging WinDBG and PyKd, also going through the source, no success
Yes, my environment is set correctly with the Python path.
Couldn't find any mention of that problem in the web.
It had always ran smoothly on different systems and configurations I had, but on my new system I get this weird message.
Details:
Windows 10 Home, version 1607, x64
WinDBG x86, build 10.0.15063.0
Python 2.7.13, but I tried many other versions as well.
Symbols path: cache*c:\symbols;srv*https://msdl.microsoft.com/download/symbols
Dell XPS 15
guy
I installed the latest pykd too, and occur the same problem.
Then I found that I hadn't installed python 2.7 at this virtualbox.
Installing python 2.7 will work.
You have installed it.I suggest you check whether python installation path is in "path" environment variable
if you don't have this register path:HKEY_LOCAL_MACHINE\SOFTWARE\Python\PythonCore\xx\PythonPath, then you should install python-2.7(x64) with Path enabled.
I had this issue when having multiple python installations on the same machine. Managed to solve it by manually creating required registry key, as I did not want to reinstall any python versions, nor change the global path/pythonpath variables.
Note that you will need x64 python for windbgx64 and x86 python for windbgx86
Let's say you want to use python 3.7x86 installed at c:\python37_x86, and python 3.6x64 installed at c:\python36_x64
Create keys leading to HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Python\PythonCore\3.7-32\InstallPath there, and set the (Default) to c:\python37_x86\ (the trailing backslash is important!)
Similarly, create keys leading to HKEY_LOCAL_MACHINE\SOFTWARE\Python\PythonCore\3.6\InstallPath there, and set the (Default) to c:\python36_x64\
Unfortunately the PYTHONPATH environment variable is still being used, and must match the referenced python version(otherwise you will encounter Fatal Python error: unable to load the file system codec . NOTE: this may only be important if one of the versions is 2.x and the other 3.x. Try making it work without this step
To circumvent the last issue I created .bat files to modify the environment and launch windbg with the correct environment.
For example for launching 32 bit windbg:
set PYTHONPATH=C:\python37_x86\Lib;[...Rest of the PYTHONPATH for this python version...]
start windbgx -debugArch x86 -c ".load c:\dev\tools\pykd\x86\pykd.dll"
WinDBG x86, build 10.0.15063.0
Python 2.7.13, but I tried many other versions as well.
You need python 2.7.13 x86
After installation you can check it visibility for pykd with command pykd.info - it should show path to python. For python 2.7 it is commonly C:\windows\system32\python27.dll
Also had the same issue, in the end it depends on which windbg version you are using, and what python versions you have installed;
If it is windbg x86, you need python 32 bits installed.
If it is windbg x64, you need python 64 bits installed.
I did not have to add any specific version to the PATH, I have 3 versions of python in my system; python2.7x86, python2.7x64 and python3x64 and if I run !pykd.info in windbgx86 it recognizes both x86 pythons and if I run it in sindbgx64 it recognizes the x64 python.
If your !pykd.info does not list any python, you probably have them mixed up (you only have pythonx86 while running windbgx64, or you only have pythonx64 while running windbgx86).
Related
I am trying to enable python support for Vim 8.0 on Windows 10.
As I understand it I need:
Vim with python support
Python installed and on the $path
matching 32 or 64 bit versions of both
I have tried
the official 32bit binary, which shows python35.dll with python 3.5.2 and 3
the 64 bit binary available from tux project which shows python36.dll as the ddynamic_python_dll with python 3.6.1
Each time I've checked the path by typing 'python --version' in cmd and confirming I'm getting the right version.
In all cases I get E370 could not load library. How do I make sure Vim is looking at the right file?
set pythonthreedll="c:\program files (x86)\python36-32\python36.dll"
And you might not want to leave that in your .vimrc while you keep changing everything else around it....
I have installed PostgreSQL Server 9.6.0 and Python 3.4.2 on Windows 2012 R2 Server.
I copied plpython3.dll to C:/Program Files/PostgreSQL/9.6/lib/
The in PostgreSQL I try running this command: CREATE EXTENSION plpython3u;
And I receive this message:
ERROR: could not load library "C:/Program Files/PostgreSQL/9.6/lib/plpython3.dll": The specified module could not be found.
Under this folder: C:\Program Files\PostgreSQL\9.6\share\extension there are plpython3u files.
How can I get PostgreSQL to recognize this Python 3 extension?
Thanks!
Copy the python34.dll file to c:\windows\system32 and name the copy python33.dll
The create language plpython3u should then work without a problem.
Exactly the same situation I faced with Postgres 9.6 Windows 10.
PL/Python3U would not get through.
Worked around it:
Installed Python34 64bit Windows 10 version.
Copied Python34.dll to c:\windows\system32 as Python33.dll and it worked.
The information is in Makefile of source installation package
We need libpython as a shared library. In Python >=2.5, configure asks Python directly. But because this has been broken in Debian for a long time (http://bugs.debian.org/695979), and to support older Python versions, we see if there is a file that is named like a shared library as a fallback.
for python windows:
ifeq ($(PORTNAME), win32)
pytverstr=$(subst .,,${python_version})
PYTHONDLL=$(subst \,/,$(WINDIR))/system32/python${pytverstr}.dll
So the write answer is:
WINDIR is : C:\Windows
pytverstr is use in makefile has a parameter to define version of python
PYTHONDLL is the location of dll
To check version of my installation, I open plpython3.dll located in C:\Program Files\PostgreSQL\9.4\lib (change path with your environnement)
With Notepad++ and search PyUnicode_AsUTF8String
the python dll version is visible in last word (in my case python33.dll)
check your installation to choice the good installer of python
SELECT version();
PostgreSQL 9.4.15, compiled by Visual C++ build 1800, 64-bit
So I need install Python 33 in 64bit
edit 2020-10-02
There is also all of these informations in doc of binary ..pgsql\doc\installation-notes.html look at title Procedural Languages
edit 2021-06-11
After install the good version of Python on your system you need copy it to C:\Windows\System32
Replacing the version of python with an old name is not a good solution because you can have librairie it not work with this version. Do that if you know risks. So if you want a newest version of python for plpython, compile it or check edb compilation to check if it contains what you need. You can ask EDB for this information.
plpython3.dll in the official package is built against python 3.3, not python 3.4. What it expect is python33.dll in system32 folder. You need to install python 3.3 for your system.
Since py33 has been phased out, you may soon get frustrated, due to lack of pre-built binary package, lxml, pyzmq etc all needs to be built from source. If you need any binary module, make sure you have a correctly set up compiler.
This may be helpful, I have struggled a lot with this. For me only worked when I installed the right version of python and added paths to environment variables. I am not sure if python 3.4.0 would be the right version for PostgreSQL Server 9.6.0 but it worked fine with PostgreSQL Server 10.0.
Try version python-3.4.0.amd64 for windows 64bit or other versions from this Python 3.4.0 downloads Link
Environment variables to add:
C:\Python34\Scripts
C:\Python34\
My Mac came with Python 2.6.9 and 2.7.6 (the default 'Python') installed. I needed several modules from the SciPy stack and installed them using MacPorts:
py27-numpy
py27-scipy
py27-matplotlib
py27-pandas
Now for whatever reason this installed another Python version alongside the ones I already had, Python 2.7.8. All the packages only work with this one. When I start a new project in XCode and point it to this new instance, /usr/bin/python2.7, nothing works and I get
'/System/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python: can't open file '
I can make XCode work with the 2.7.6 version, /usr/bin/python, but then none of the packages I need are available.
Is there any way to either make XCode work with this other python instance, or to remove the 2.7.6 entirely and replace the default python with the new one?
The correct path to the MacPorts python is /opt/local/bin/python2.7. By using the MacPorts version of Python, you are ensured that all of the necessary dependencies are found. I was able to follow these instructions and get everything to work. The only catch was in step 16 I had to manually enter the path because /opt was not visible.
Alternatively, you could try adding the MacPorts library path to your PYTHONPATH. Just add
export PYTHONPATH=$PYTHONPATH:/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/
to your .bash_profile. I will warn you that when I tried mixing Pythons in the past I frequently got errors relating to trying to import wrong module.
How do I install GVIM for Windows with Python3 support? I have installed VIM 7.4 which says in it's version file (run :version command) "+python3/dyn" and "-DDYNAMIC_PYTHON3_DLL=\"python32.dll\". So it looks like it's ready to support Python 3. When I run
:echo has("python3")
it returns zero. And if I test with
:py3 print("hello")
it says it cannot load python32.dll.
Here is an approach that I used to get VIM 7.x to work with Python 3.x.
Install a VIM of your preference. Suggestion: get the latest version from VIM.org, though this site seems to have only 32-bit versions. If you want 64-bit (my preference) get a pre-built at https://bintray.com/veegee/generic/vim_x64 or choose your own pre-built elsewhere, or build your own.
Type the command :py3 print("hello")
It probably will not find the python dll, in which case it gives an error message like cannot load pythonXX.dll where XX is a two-digit number. In my case, VIM was looking for python35.dll, which comes from Python 3.5.1 (and probably any Python 3.5.x). The number will vary depending on the version of VIM you use.
Go find a matching Python distribution. Matching means that both VIM and Python must be either 32-bit or 64-bit, and the DLL that VIM wants (in step 3) is present. So for example, it appears that Python 3.5.x provides python35.dll. Install it.
I don't recall having to do anything special to get VIM to find the python DLL, other than ensuring that the directory it is in should be in the path, and I think it already was. If not, add the directory with the DLL to your path.
Retry step 2. It should work now.
If in the future you upgrade VIM or Python, you may need to upgrade the other one at the same time, to ensure that the test in step 2 still works.
The problem that makes this question so hard is that specific solutions very quickly become obsolete. The day the solution is posted the version of vim or python is updated or links change. The steps provided by #mark-colon are fantastic but oriented for vim-7.
Generic instructions:
vim and python need to be in sync on many different levels:
Both need to be 32bit or 64bit
Vim needs to find a specific python dll version. It depends on who compiled your version of gvim. For example, gvim-8.1.x may use python3.6 or python3.7 and the exact version is required! Sometimes you can use: gvim --version to see what specific dll is being searched by vim at launch, otherwise you need to find out from where you downloaded gvim. This is the version of python that you must search the internet and install on your system. (Alternatively, if the version of python is more important to you than the version of vim, you can try to find a version of vim that was compiled for python but this will be harder to find.)
Make sure the directory that holds the python dll needs to be on the %PATH% environment variable. (Note: some just copying the python dll to the $VIM folder to get things working only works in the short term. You don't have all the necessary python libraries that are often assumed to be available.)
Finally, verify with ex command :python2 print("hello") or :python3 print("hello") depending on what version of python you wanted.
Specific links (if you must):
Note: these will all soon be out of date, but the following are some links to various compiled versions of gvim and python that could work together:
For gvim-8.1.x & python-3.7.x or python-2.7.x as of 2018-08:
https://tuxproject.de/projects/vim/
http://winpython.github.io/ or https://www.python.org/downloads
For gvim-8.1.x & python-3.6.x or python-2.7.x as of 2018-08:
https://github.com/vim/vim-win32-installer/releases
https://www.python.org/downloads
For gvim-7.4.x & python-3.5.x or python-2.7.x as of 2018-08:
https://bintray.com/veegee/generic/vim_x64
https://www.python.org/downloads
Unfortunately this took me a day to figure out. Here's the simplest way to remedy this problem, if you are looking to have Python3 support with GVIM 7.3+ on Windows.
I am running 64-bit Windows 8, but, make sure you grab a 32-bit version of Python. You will most likely have a 32-bit version of GVIM by default, and those 2 need to match. Specifically, grab a 3.2.x version of Python3 because that's what VIM is looking for as far as a DLL is concerned (python32.dll). Don't bother with the latest version of Python 3, 3.4.0 at the time of writing; and if you do need that, then I'm not sure how to help.
Once you have Python 3.2.x installed, make sure you do this last tricky part:
The python32.dll is not placed in system32 folder, it is actually in the C:\Windows\SysWOW64 folder. You need to add "C:\Windows\SysWOW64" to your PATH environment variable.
Now re-try your python3 tests in GVIM and it should be successful.
I use Haroogan's compiled version, it's great and has a 64-bit version for windows.
EDIT:
veegee's version seems to be a good alternative. Thanks to Markus Meskanen in the comment.
I have tested that you should use the same architecture for both vim and python.
see https://vi.stackexchange.com/questions/11004/how-to-get-python-support
If you just need python feature in vim, download python36.dll and put in $VIM and verify by :echo has('python3')
I'm trying to get Python support in gVim on Windows. Is there a way to accomplish that?
I'm using:
Windows XP SP3
gVim v. 7.3
Python 2.7.13 (ActivePython through Windows Installer binaries)
I had the same issue, but on Windows 7, and a restart didn't fix it.
I already had gVim 7.3 installed. At the time of writing the current Python version was 3.3, so I installed that. But :has ("python") and :has ("python3") still returned 0.
After much trial and error, I determined that:
If gVim is 32-bit, and it usually is even on 64-bit Windows (you can confirm using the :version command), then you need the 32-bit python installation as well
No restart of Windows 7 is required
The version of python needs to match the version that gVim is compiled for as it looks for a specific DLL name. You can work this out from the :version command in gVim, which gives something like:
Compilation: cl -c /W3 /nologo -I. -Iproto -DHAVE_PATHDEF -DWIN32
-DFEAT_CSCOPE -DFEAT_ NETBEANS_INTG -DFEAT_XPM_W32 -DWINVER=0x0400 -D_WIN32_WINNT=0x0400 /Fo.\ObjGOLYHTR/ / Ox /GL -DNDEBUG /Zl /MT -DFEAT_OLE -DFEAT_MBYTE_IME -DDYNAMIC_IME -DFEAT_GUI_W32 -DDYNAMI C_ICONV -DDYNAMIC_GETTEXT -DFEAT_TCL -DDYNAMIC_TCL
-DDYNAMIC_TCL_DLL=\"tcl83.dll\" -DDYNAM IC_TCL_VER=\"8.3\" -DFEAT_PYTHON -DDYNAMIC_PYTHON -DDYNAMIC_PYTHON_DLL=\"python27.dll\" -D FEAT_PYTHON3 -DDYNAMIC_PYTHON3 -DDYNAMIC_PYTHON3_DLL=\"python31.dll\" -DFEAT_PERL -DDYNAMI C_PERL -DDYNAMIC_PERL_DLL=\"perl512.dll\" -DFEAT_RUBY -DDYNAMIC_RUBY -DDYNAMIC_RUBY_VER=19 1 -DDYNAMIC_RUBY_DLL=\"msvcrt-ruby191.dll\" -DFEAT_BIG /Fd.\ObjGOLYHTR/ /Zi
So the above told me that I don't actually want python 3.3, I need 3.1 (or 2.7). After installing python 3.1, :has ("python") still returns 0, but :has ("python3") now returns 1. That should mean that python based scripts will now work!
I imagine future versions of gVim may be compiled against other versions of python, but using this method should let you work out which version is required.
Usually, python support is built in the official gvim distribution.
You will need to install python though: Python Downloads
to check if vim supports python:
:echo has("python")
I encountered this problem on Windows 7 64-bit. I realized I was using 64-bit Python 2.7.3 and 32-bit vim 7.3-46. I reinstalled both as 32-bit versions and then restarted the computer. Now it works.
If you have installed Python via one of the Windows installers it is probably compiled with Python 2.7 support. You can verify this by running:
:version
It will spit out all the options Vim was compiled with. Yours should say something like
+python/dyn +python3\dyn
This means you have support for python 2.7 and 3.x. If you already have 2.5 it won't work. You will need to upgrade to either 2.7 or 3.x.
Sorry for a late contribution.
The problem is that you can not mix x86 vim with x64 python libs, and all suggested solutions boil down to reinstalling x86 python.
Well, I do not want to reinstall Python, Ruby and who knows what else dependent on those just because vim does not officially provide fair x64 distribution on windows. The good news is that you can still find it well hidden at http://vim.wikia.com/wiki/Where_to_download_Vim . Good luck, and take care of Python library versions.
The accepted answer didn't solve my problem, so I decide to post the solution I found after some efforts.
First, as the accepted answer pointed out, you'll need both gVim compiled with python enabled, and a corresponding python installation. Make sure they are both 32-bit or 64-bit.
I found that the default build from www.vim.org didn't enable python, also it seemed to be 32-bit, which didn't match my python27. What I ended up with was the build "gvim_8.0.0003_x64.zip" from this vim Git repository
I then unzipped it, copied the "vim80" folder into the official vim installation location (created by the 32-bit installation downloaded www.vim.org).
Now vim works with my 64-bit python2.7 .
UPDATE 02/24/2017:
The procedure above failed on another machine where the local python installation is 2.7.9 . My Python version is 2.7.11 when I succeeded.
So, it seems the build from the vim Git repository works for a specific Python version. Try update your Python installation to 2.7.11 if you can. If you have to use an older version of Python, then maybe you need to build the Vim source code on your machine. It's not too hard following the instructions, and use the Visual Studio provided cmd instead of the Windows default cmd.
Add following scripts to your .vimrc
set pythonthreedll = python36.dll
Most distribution of vim in Windows is loading python dynamically, you must tell vim what the dll is, and make sure that python36.dll is in your PATH environment variable.
I had a similar problem. I've been enjoying vim's omni-completion feature for some years,using Windows XP, Python 2.7, gVim 7. Recently I moved to a new PC running Windows 8.1. I installed gVim and the plugins I like, then tried out everything. Omni-completion gave an error, saying I needed the version of vim compiled with Python support. At that stage, I had not yet installed Python. The solution was to install Python then re-install vim. Omni-conpletion now works. Perhaps the order of installation matters.
When I typed :version, it revealed that my Vim was not compiled with Python. Perhaps because I did not have Python (32-bit?) at the time.
I did install 32-bit Python as suggested, but reinstalling Vim seemed necessary.
After reading the above, I can confirm that on Win8.1 it does matter the order you install them (least for me it did). I had 32bit VIM 7.4 installed for a few months, then tried adding Python and couldn't do it. Left Python 2.7.9 installed and uninstalled/reinstalled VIM and now it works.
Download the one called "OLE GUI executable"
After trying all answers in this thread without success, the following worked for me (Win10, Python 2.7 32bit, gvim 7.4 32bit):
Reinvoke the Python Installer, select Change Python
Select the Option Add Python to Path, which is off by default
After the installer is done, restart your machine