Installing SetupTools on 64-bit Windows - python

I'm running Python 2.7 on Windows 7 64-bit, and when I run the installer for setuptools it tells me that Python 2.7 is not installed. The specific error message is:
`Python Version 2.7 required which was not found in the registry`
My installed version of Python is:
`Python 2.7 (r27:82525, Jul 4 2010, 07:43:08) [MSC v.1500 64 bit (AMD64)] on win32`
I'm looking at the setuptools site and it doesn't mention any installers for 64-bit Windows. Have I missed something or do I have to install this from source?

Problem: you have 64-bit Python, and a 32-bit installer. This will cause problems for extension modules.
The reasons why the installer doesn't finds Python is the transparent 32-bit emulation from Windows 7. 64-bit and 32-bit programs will write to different parts of the Windows registry.
64-bit: HKLM|HKCU\SOFTWARE\
32-bit: HKLM|HKCU\SOFTWARE\wow6432node\.
This means that the 64-bit Python installer writes to HKLM\SOFTWARE\Python, but the 32-bit setuptools installer looks at HKLM\SOFTWARE\wow6432node\Python (this is handled by windows automatically, programs don't notice). This is expected behavior and not a bug.
Usually, you have these choices:
the "clean" way: use 32-bit Python if you have to use 32-bit modules or extensions
the other "clean" way: only use 64-bit installers when using 64-bit Python (see below)
what the answer above suggests: copy HKLM\SOFTWARE\Python to HKLM\SOFTWARE\wow6432node\Python, but this will cause problems with binary distributions, as 64-bit Python can't load 32-bit compiled modules (do NOT do this!)
install pure Python modules with setuptools instead of the distutils installer (easy_install or pip)
For setuptools itself, for example, you can't use a 32-bit installer for 64-bit Python as it includes binary files. But there's a 64-bit installer at http://www.lfd.uci.edu/~gohlke/pythonlibs/ (has many installers for other modules too). Nowadays, many packages on PyPi have binary distributions, so you can install them via pip.

Apparently (having faced related 64- and 32-bit issues on OS X) there is a bug in the Windows installer. I stumbled across this workaround, which might help - basically, you create your own registry value HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Python\PythonCore\2.6\InstallPath and copy over the InstallPath value from HKEY_LOCAL_MACHINE\SOFTWARE\Python\PythonCore\2.6\InstallPath. See the answer below for more details.
If you do this, beware that setuptools may only install 32-bit libraries.
NOTE: the responses below offer more detail, so please read them too.

I made a registry (.reg) file that will automatically change the registry for you. It works if it's installed in "C:\Python27":
Download 32-bit version HKEY_LOCAL_MACHINE|HKEY_CURRENT_USER\SOFTWARE\wow6432node\
Download 64-bit version HKEY_LOCAL_MACHINE|HKEY_CURRENT_USER\SOFTWARE\

Yes, you are correct, the issue is with 64-bit Python and 32-bit installer for setuptools.
The best way to get 64-bit setuptools installed on Windows is to download ez_setup.py to C:\Python27\Scripts and run it. It will download appropriate 64-bit .egg file for setuptools and install it for you.
Source: http://pypi.python.org/pypi/setuptools
P.S. I'd recommend against using 3rd party 64-bit .exe setuptools installers or manipulating registry

Create a file named python2.7.reg (registry file) and put this content into it:
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Python\PythonCore\2.7]
[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Python\PythonCore\2.7\Help]
[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Python\PythonCore\2.7\Help\MainPythonDocumentation]
#="C:\\Python27\\Doc\\python26.chm"
[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Python\PythonCore\2.7\InstallPath]
#="C:\\Python27\\"
[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Python\PythonCore\2.7\InstallPath\InstallGroup]
#="Python 2.7"
[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Python\PythonCore\2.7\Modules]
[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Python\PythonCore\2.7\PythonPath]
#="C:\\Python27\\Lib;C:\\Python27\\DLLs;C:\\Python27\\Lib\\lib-tk"
And make sure every path is right!
Then run (merge) it and done :)

Get the file register.py from this gist. Save it on your C drive or D drive, go to CMD to run it with:
'python register.py'
Then you will be able to install it.

For 64-bit Python on Windows download ez_setup.py and run it; it will download the appropriate .egg file and install it for you.
At the time of writing the .exe installer does not support 64-bit versions of Python for Windows, due to a distutils installer compatibility issue.

To allow Windows installers to find the installed Python directory in Windows 7, OR, change which Python installation to install an installer into, add the installed path into the InstallPath registry key's (Default) value:
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Python\PythonCore\2.X\InstallPath
Where "X" is the Python version (that is, 2.5, 2.6, or 2.7).

I tried the above and adding the registry keys to the LOCALMACHINE was not getting the job done. So in case you are still stuck , try this.
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\SOFTWARE\Python]
[HKEY_CURRENT_USER\SOFTWARE\Python\PythonCore]
[HKEY_CURRENT_USER\SOFTWARE\Python\PythonCore\2.7]
[HKEY_CURRENT_USER\SOFTWARE\Python\PythonCore\2.7\Help]
[HKEY_CURRENT_USER\SOFTWARE\Python\PythonCore\2.7\Help\Main Python Documentation]
#="C:\Python27\Doc\python272.chm"
[HKEY_CURRENT_USER\SOFTWARE\Python\PythonCore\2.7\InstallPath]
#="C:\Python27\"
[HKEY_CURRENT_USER\SOFTWARE\Python\PythonCore\2.7\InstallPath\InstallGroup]
#="Python 2.7"
[HKEY_CURRENT_USER\SOFTWARE\Python\PythonCore\2.7\Modules]
[HKEY_CURRENT_USER\SOFTWARE\Python\PythonCore\2.7\PythonPath]
#="C:\Python27\Lib;C:\Python27\DLLs;C:\Python27\Lib\lib-tk"
Copy paste the above in notepad and save it as Python27.reg . Now run/merge the file as mentioned in the answers above. (Make sure the paths of Python installation are corrected as per your installation.
It simply does ,what the above answers suggest for a local machine ,to the current user.

Here is a link to another post/thread. I was able run this script to automate registration of Python 2.7. (Make sure to run it from the Python 2.x .exe you want to register!)
To register Python 3.x I had to modify the print syntax and import winreg (instead of _winreg), then run the Python 3 .exe.
https://stackoverflow.com/a/29633714/3568893

You can find 64bit installers for a lot of libs here: http://www.lfd.uci.edu/~gohlke/pythonlibs/

Related

Error during: CREATE EXTENSION plpython3u; on PostgreSQL 9.6.0

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\

numpy python 3.4.1 : Python 3.4 not found in registry

I want to plot few graphs with matplotlib and I have a windows machine Firstly I need to install, so I download the file from http://matplotlib.org/downloads.html . Well, when I tried to run, it throws a pop up saying it failed to find the version 3.4 in registry. This is a bit strange because my python version is 3.4.1.
Of course, I did search through the forum. I happened to look into numpy python 3.4.1 installation: Python 3.4 not found in registry which is same as my problem. but my first question:
1) The matplotlib official page gives me a direct link to install ".exe" for windows with python version 3.4. If this is true then why this problem should occur in the first place.
2) My second question, how one can actually find whether the downloading package version is the right match for the current python version installed on local PC.
The windows .exe installer should work for all sub-versions of a given Python installation, this means that if you use the 3.4 installer it should work for 3.4.0, 3.4.1, and 3.4.2.
You need to check that you are using the correct version of the installer, 32-bit or 64-bit. The installer should match the Python version you are using, which may or may not match your system version. This is to say that if you had a 64-bit system and used 32-bit Python, you should use the 32-bit installer.
If it still doesn't work, I'd suggest you re-install Python and try again, it's possible that something has messed with your registry settings.
Originally I thought that the sub-version mattered, but in fact it does not. I raised an issue with matplotlib here and was corrected by Christoph Gohlke who maintains the .exe installations.
Incidentally (for someone reading this in the future as you know yours) if you need to find your current Python version you can simply type python -V in the command line and it'll return the details, for example mine returns:
Python 3.4.0
I had the same problem installing matplotlib-1.4.3.win-amd64-py3.4.exe on python 3.4.3: version 3.4 not found in registry. Looking in the registry under HKEY_LOCAL_MACHINE\SOFTWARE\ there was no Python key, so matplotlib is right.
Further searching I found this SO article, Installing SetupTools on 64-bit Windows, that provided a registry script to add the necessary keys for Python 2.7. I modified the script for 3.4 and added the keys to the registry. Install of matplotlib then completed successfully. It seems the registry keys didn't get added when I installed Python 3.4.3 (sub-installer that installs registry keys is invoked at user privilege level??).
The modified registry key file I used. Save it to a text file with a .reg extension.
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Python]
[HKEY_LOCAL_MACHINE\SOFTWARE\Python\PythonCore]
[HKEY_LOCAL_MACHINE\SOFTWARE\Python\PythonCore\3.4]
[HKEY_LOCAL_MACHINE\SOFTWARE\Python\PythonCore\3.4\Help]
[HKEY_LOCAL_MACHINE\SOFTWARE\Python\PythonCore\3.4\Help\Main Python Documentation]
#="C:\\Python34\\Doc\\python343.chm"
[HKEY_LOCAL_MACHINE\SOFTWARE\Python\PythonCore\3.4\InstallPath]
#="C:\\Python34\\"
[HKEY_LOCAL_MACHINE\SOFTWARE\Python\PythonCore\3.4\InstallPath\InstallGroup]
#="Python 3.4"
[HKEY_LOCAL_MACHINE\SOFTWARE\Python\PythonCore\3.4\Modules]
[HKEY_LOCAL_MACHINE\SOFTWARE\Python\PythonCore\3.4\PythonPath]
#="C:\\Python34\\Lib;C:\\Python34\\DLLs;C:\\Python34\\Lib\\lib-tk"
Then double click the .reg file to add the registry.
I had this problem with Python3.4.2 and went back and did a reinstall. This time I paid attention to what I was doing. While installing Python3.4.2 (or 2.7) a list of options popup. The last item on the list of options is "Add Python to path". On my installation this option was marked with an X and I assume it was on the first installation. I removed the X and continued the install of Python. When I installed numpy, it found Python in the registry and loaded okay.
Open regedit.
Find python in HKEY_LOCAL_MACHINE.
Export it to some location on your hard drive.
Open the exported file in any editor.
Replace all HKEY_LOCAL_MACHINE with HKEY_CURRENT_USER and save
the file.
Now just double click on the .reg file to add this key to registry.
If you go back to the registry using regedit, you will find python in
HKEY_CURRENT_USER as well.
I really wish 'pip install numpy' worked just like it did for python 2.7.

Python 3.3. not found in registry [duplicate]

I am trying to install biopython to run with Python 3.3 on a Windows7 computer.
I have downloaded the biopython executable biopython-1.61.win32-py3.3-beta.exe. When I attempt to run the executable, however, I get the message "Python version 3.3 is required, which is not found in the registry." Python version 3.3 is present on my computer. I have been running programs through it for a month or two. It was installed from the file python-3.3.0.amd64.msi, and is located in the Program Files (x86) directory.I have tried reinstalling Python 3.3 but get the same error message.
Does anyone know how to get around this problem?
Python.org provides Windows installers in two flavours, 32 bit ("win32") and 64 bit ("amd64"). You need matching library installers for your Python version. You are trying to use a 32 bit Biopython installer with a 64 bit Python.
As instructed here http://biopython.org/wiki/Download there are experimental 64 bit Windows installers for Biopython, NumPy, etc here: http://www.lfd.uci.edu/~gohlke/pythonlibs/
Or, you can install the 32-bit version of Python 3.3 for Windows, and then use biopython-1.61.win32-py3.3-beta.exe
You can try to solve this problem by fixing a blank option in the Windows registry.
https://stackoverflow.com/a/11507968/3962648 provide details of similar issue when installing numpy.
In short, you can just run the windows command line and type in: "reg copy HKEY_LOCAL_MACHINE\SOFTWARE\Python HKLM\SOFTWARE\Wow6432Node\Python /s"
probelm is windows 64bit and biopython 32bit...
to get the 64bit version of biopython get this one:
http://www.lfd.uci.edu/~gohlke/pythonlibs/

Installation of biopython - python 3.3 not found in registry

I am trying to install biopython to run with Python 3.3 on a Windows7 computer.
I have downloaded the biopython executable biopython-1.61.win32-py3.3-beta.exe. When I attempt to run the executable, however, I get the message "Python version 3.3 is required, which is not found in the registry." Python version 3.3 is present on my computer. I have been running programs through it for a month or two. It was installed from the file python-3.3.0.amd64.msi, and is located in the Program Files (x86) directory.I have tried reinstalling Python 3.3 but get the same error message.
Does anyone know how to get around this problem?
Python.org provides Windows installers in two flavours, 32 bit ("win32") and 64 bit ("amd64"). You need matching library installers for your Python version. You are trying to use a 32 bit Biopython installer with a 64 bit Python.
As instructed here http://biopython.org/wiki/Download there are experimental 64 bit Windows installers for Biopython, NumPy, etc here: http://www.lfd.uci.edu/~gohlke/pythonlibs/
Or, you can install the 32-bit version of Python 3.3 for Windows, and then use biopython-1.61.win32-py3.3-beta.exe
You can try to solve this problem by fixing a blank option in the Windows registry.
https://stackoverflow.com/a/11507968/3962648 provide details of similar issue when installing numpy.
In short, you can just run the windows command line and type in: "reg copy HKEY_LOCAL_MACHINE\SOFTWARE\Python HKLM\SOFTWARE\Wow6432Node\Python /s"
probelm is windows 64bit and biopython 32bit...
to get the 64bit version of biopython get this one:
http://www.lfd.uci.edu/~gohlke/pythonlibs/

How to enable Python support in gVim on Windows?

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

Categories