mysql for python 2. 7 says Python v2.7 not found

2019-02-04 15:52发布

I have downloaded mysql-connector-python-1.0.7-py2.7.msi from MySQL site and try to install but it gives error that

Python v2.7 not found. We only support Microsoft Windows Installer(MSI) from python.org.

I am using Official Python v 2.7.3 on windows XP SP3 with MySQL esssential5.1.66

Need Help ???

8条回答
Melony?
2楼-- · 2019-02-04 16:16

In my case, I installed python 2.7.14 x64 only for my user. I have to look for this in my registry:

HKEY_CURRENT_USER\Software\Python

, export them, open the exported .reg file with a text editor, replace all occurrence of HKEY_CURRENT_USER with HKEY_LOCAL_MACHINE, and import it.

The result is: (remember to change the install dir to yours)

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\Software\Python]

[HKEY_LOCAL_MACHINE\Software\Python\PythonCore]

[HKEY_LOCAL_MACHINE\Software\Python\PythonCore\2.7]

[HKEY_LOCAL_MACHINE\Software\Python\PythonCore\2.7\Help]

[HKEY_LOCAL_MACHINE\Software\Python\PythonCore\2.7\Help\Main Python Documentation]
@="D:\\Desarrollo\\entornos\\python27_x64\\Doc\\python2714.chm"

[HKEY_LOCAL_MACHINE\Software\Python\PythonCore\2.7\InstallPath]
@="D:\\Desarrollo\\entornos\\python27_x64\\"

[HKEY_LOCAL_MACHINE\Software\Python\PythonCore\2.7\InstallPath\InstallGroup]
@="Python 2.7"

[HKEY_LOCAL_MACHINE\Software\Python\PythonCore\2.7\Modules]

[HKEY_LOCAL_MACHINE\Software\Python\PythonCore\2.7\PythonPath]
@="D:\\Desarrollo\\entornos\\python27_x64\\Lib;D:\\Desarrollo\\entornos\\python27_x64\\DLLs;D:\\Desarrollo\\entornos\\python27_x64\\Lib\\lib-tk"

And the installation afterwards is smooth as a breeze. Viola!

查看更多
Lonely孤独者°
3楼-- · 2019-02-04 16:19

You need to make sure that you download the version with the correct "bitness" (32/64 bit), matching the "bitness" of your Python installation!

I ran into the same problem (with Python 3.7.2, though).

I had Python 3.7.2 32 bit already installed, but accidentally downloaded the 64 bit version of the MySQL Connector for Python 3.7.

When I tried to install the connector, I got the same error message:

error message

Solution: I just downloaded the 32 bit version instead, and everything worked (installing the connector and actually connecting to the database)

查看更多
Lonely孤独者°
4楼-- · 2019-02-04 16:23

I met the similar problem under Windows 7 when installing mysql-connector-python-1.0.7-py2.7.msi and mysql-connector-python-1.0.7-py3.2.msi.

After changing from "Install only for yourself" to "Install for all users" when installing Python for windows, the "python 3.2 not found" problem disappear and mysql-connector-python-1.0.7-py3.2.msi was successfully installed.

I guess the problem is that mysql connector installer only looks for HKEY_LOCAL_MACHINE entries, and the things it looks for might be under HKEY_CURRENT_USER etc. So the solution that change the reg table directly also works.

查看更多
狗以群分
5楼-- · 2019-02-04 16:27

If you're still experiencing this with x64 or other python modules, I'd recommend this website Python Extensions for x64/x32

查看更多
We Are One
6楼-- · 2019-02-04 16:28

The Solution I get for this problem is

I have found Adding Python to Registry, the script as follows applicable for python v 2.0 and above: Register a Python Interpreter

#
# script to register Python 2.0 or later for use with win32all 
# and other extensions that require Python registry settings
#
# written by Joakim Low for Secret Labs AB / PythonWare
#
# source:
# http://www.pythonware.com/products/works/articles/regpy20.htm

import sys
from _winreg import *

# tweak as necessary

version = sys.version[:3]
installpath = sys.prefix
regpath = "SOFTWARE\\Python\\Pythoncore\\%s\\" % (version)
installkey = "InstallPath"
pythonkey = "PythonPath"
pythonpath = "%s;%s\\Lib\\;%s\\DLLs\\" % (
    installpath, installpath, installpath)


def RegisterPy():
    try:
        reg = OpenKey(HKEY_LOCAL_MACHINE, regpath)
    except EnvironmentError:
        try:
            reg = CreateKey(HKEY_LOCAL_MACHINE, regpath)
            SetValue(reg, installkey, REG_SZ, installpath)
            SetValue(reg, pythonkey, REG_SZ, pythonpath)
            CloseKey(reg)
        except:
            print "*** Unable to register!"
            return
        print "--- Python", version, "is now registered!"
        return

    if (QueryValue(reg, installkey) == installpath and
            QueryValue(reg, pythonkey) == pythonpath):
        CloseKey(reg)
        print "=== Python", version, "is already registered!"
        return

    CloseKey(reg)
    print "*** Unable to register!"
    print "*** You probably have another Python installation!"

if __name__ == "__main__":
    RegisterPy()

Save it with any name. Run it from python interpreter and Thats ALL!!

查看更多
Summer. ? 凉城
7楼-- · 2019-02-04 16:39

I solved this problem by using 32bit python

查看更多
登录 后发表回答