windows pip install MySQL-python

环境,windows64位下,python版本是2.7.11,因为操作数据库需要安装mysql-python,所以直接命令行下,

命令:pip install mysql-python

报错:

_mysql.c(42) : fatal error C1083: Cannot open include file: 'config-win.h': No s
uch file or directory
error: command 'C:\\Program Files (x86)\\Common Files\\Microsoft\\Visual C++ for
 Python\\9.0\\VC\\Bin\\cl.exe' failed with exit status 2

起初以为需要安装VC for python,,,下载后还是不行
后来直接下载源文件mysql for python
命令:python set.py install
还是报错!!!
解决方案:
在这里下载对应文件
http://www.codegood.com/downloads
因为是我 windows64 位 所以MySQL-python-1.2.3.win-amd64-py2.7.exe
其他的在上面链接,按照自己的对应版本下载,双击即可
要想验证一下,可以这样做:

命令行下>>>import MySQLdb
直接打印>>>print MySQLdb
<module 'MySQLdb' from 'C:\Python27\lib\site-packages\MySQLdb\__init__.pyc'>

OK!,收工!!

error: Microsoft Visual C++ 9.0 is required (Unable to find vcvarsall.bat). Get it from http://aka.ms/vcpython27

下载:Microsoft Visual C++ Compiler for Python 2.7
https://www.microsoft.com/en-gb/download/confirmation.aspx?id=44266

python version 2.7 required,which was not found in the registry

安装PIL-1.1.7.win32-py2.7的时候,不能再注册表中识别出来python2.7
方法:新建一个register.py 文件,把一下代码贴进去,保存

#
# script to register Python 2.0 or later for use with win32all
# and other extensions that require Python registry settings
#
# written by Joakim Loew for Secret Labs AB / PythonWare
#
# source:
# http://www.pythonware.com/products/works/articles/regpy20.htm
#
# modified by Valentine Gogichashvili as described in http://www.mail-archive.com/distutils-sig@python.org/msg10512.html
 
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_CURRENT_USER, regpath)
    except EnvironmentError as e:
        try:
            reg = CreateKey(HKEY_CURRENT_USER, 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()

按F5执行即显示:

显示“python 2.7 is already registered”
再安装setuptools的时候,就能自动识别出来python2.7了。
win7是 64的原因,在安装python(32位)时,如果选择只为当前用户,以上问题是不会出现的,如果选择所有用户,那就用上面的方法解决吧。

在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

道知极限编程

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值