简体   繁体   English

mysql for python 2. 7说没有找到Python v2.7

[英]mysql for python 2. 7 says Python v2.7 not found

I have downloaded mysql-connector-python-1.0.7-py2.7.msi from MySQL site and try to install but it gives error that 我从MySQL站点下载了mysql-connector-python-1.0.7-py2.7.msi并尝试安装,但它给出了错误

Python v2.7 not found. 找不到Python v2.7。 We only support Microsoft Windows Installer(MSI) from python.org. 我们只支持python.org上的Microsoft Windows Installer(MSI)。

I am using Official Python v 2.7.3 on windows XP SP3 with MySQL esssential5.1.66 我使用MySQL esssential5.1.66在Windows XP SP3上使用官方Python v 2.7.3

Need Help ??? 需要帮忙 ???

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 . 我在安装mysql-connector-python-1.0.7-py2.7.msimysql-connector-python-1.0.7-py3.2.msi时在Windows 7下遇到了类似的问题。

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. 安装Python for Windows后,从"Install only for yourself"更改为"Install only for yourself" "Install for all users"安装"Install for all users""python 3.2 not found"问题消失,并成功安装了mysql-connector-python-1.0.7-py3.2.msi

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. 我想问题是mysql连接器安装程序只查找HKEY_LOCAL_MACHINE条目,它查找的内容可能在HKEY_CURRENT_USER等之下。所以直接更改reg表的解决方案也可以。

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 我发现将Python添加到Registry,适用于python v 2.0及更高版本的脚本如下:注册Python解释器

#
# 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!! 从python解释器运行它,并且全部!

This problem mainly comes with 64 bit windows. 这个问题主要是64位窗口。 download MySQL for python 64 bit on this link http://www.codegood.com/archives/129 and download MySQL-python-1.2.3.win-amd64-py2.7.exe (1.0 MiB) This will install MySQL for python. 在此链接http://www.codegood.com/archives/129下载MySQL for python 64位并下载MySQL-python-1.2.3.win-amd64-py2.7.exe(1.0 MiB)这将安装MySQL for蟒蛇。

Windows 10 (64bit): Windows 10(64位):
Indeed, I've had a similar issue and couldn't install the python 2.7 connector for MySQL. 实际上,我遇到了类似的问题,无法为MySQL安装python 2.7连接器。

Prior to this I've installed Python 2.7.15 with the Windows x86-64 MSI installer , 在此之前,我已经使用Windows x86-64 MSI installer安装了Python 2.7.15
this was while I had Python 3 installed on my machine. 这是我在我的机器上安装Python 3

The Windows x86 MSI installer did the trick, I've installed it to override the previous version of Python 2.7.15, then installed the connector (this time it gave no error messages). Windows x86 MSI installer完成了这个技巧,我已经安装它来覆盖以前版本的Python 2.7.15,然后安装了连接器(这次没有给出任何错误消息)。

Then rechecked the status in the MySQL installer and voilà: 然后重新检查MySQL安装程序中的状态并发表声明:
Python27连接器被识别

如果您仍然使用x64或其他python模块遇到此问题,我建议使用此网站Python扩展x64 / x32

I had this problem because I use Python only from within SPSS . 我有这个问题,因为我只在SPSS中使用Python。 I resolved this problem by manually adding two registry keys: 我通过手动添加两个注册表项解决了这个问题:

HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\2.7\\InstallPath

set to 调成

C:\\Program Files\\IBM\\SPSS\\Statistics\\24\\Python

and

HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\2.7\\PythonPath

set to 调成

C:\\Program Files\\IBM\\SPSS\\Statistics\\24\\Python\\Lib

This easily fixed the issue on my previous as well as current laptops. 这很容易解决我以前和现在的笔记本电脑上的问题。

You need to make sure that you download the version with the correct "bitness" (32/64 bit), matching the "bitness" of your Python installation! 您需要确保使用正确的“位数”(32/64位)下载版本,与Python安装的“位数”相匹配!

I ran into the same problem (with Python 3.7.2, though). 我遇到了同样的问题(尽管使用Python 3.7.2)。

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. 我已经安装了Python 3.7.2 32位 ,但是意外地下载了64位版本的MySQL Connector for Python 3.7。

When I tried to install the connector, I got the same error message: 当我尝试安装连接器时,我收到了相同的错误消息:

错误信息

Solution: I just downloaded the 32 bit version instead, and everything worked (installing the connector and actually connecting to the database) 解决方案:我刚刚下载了32位版本,一切正常(安装连接器并实际连接到数据库)

In my case, I installed python 2.7.14 x64 only for my user. 就我而言,我只为我的用户安装了python 2.7.14 x64。 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. ,导出它们,使用文本编辑器打开导出的.reg文件,将所有出现的HKEY_CURRENT_USER替换为HKEY_LOCAL_MACHINE ,然后导入它。

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! 中提琴!

我使用32位python解决了这个问题

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM