Python 2.7-在Windows 8上安装MySQL Python时出错

Python 2.7-在Windows 8上安装MySQL Python时出错,python,mysql,windows,Python,Mysql,Windows,我已经在这件事上撞了两天多的墙,没有任何进展 我正在尝试在我的Windows 8(讨厌的Windows 8)盒上安装Python MySQL连接器 我正在使用Python 2.7。我最初收到一个错误: 找不到vcvarsall.bat 我做了一些研究,发现我需要在我的机器上安装VS2008(VC++编译器),我安装了express版本。我还将ProductDir值和vcvarsall.bat路径添加到注册表中的以下项: HKEY\U LOCAL\U MACHINE\SOFTWARE\Wow643

我已经在这件事上撞了两天多的墙,没有任何进展

我正在尝试在我的Windows 8(讨厌的Windows 8)盒上安装Python MySQL连接器

我正在使用Python 2.7。我最初收到一个错误:

找不到vcvarsall.bat

我做了一些研究,发现我需要在我的机器上安装VS2008(VC++编译器),我安装了express版本。我还将ProductDir值和vcvarsall.bat路径添加到注册表中的以下项:

HKEY\U LOCAL\U MACHINE\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\9.0\Setup\VC.

我还添加了VS90COMNTOOLS环境变量,路径为vcvarsall.bat。运行以下操作时,我仍会遇到错误:

 pip install MySQL-python
非常感谢您提供的任何意见。。。谢谢

该错误列在pip.log的以下代码段中:

Traceback (most recent call last):

  File "<string>", line 1, in <module>

  File "c:\users\t\appdata\local\temp\pip_build_T\MySQL-python\setup.py", line 21, in <module>

    setuptools.setup(**metadata)

  File "C:\Python27\lib\distutils\core.py", line 152, in setup

    dist.run_commands()

  File "C:\Python27\lib\distutils\dist.py", line 953, in run_commands

    self.run_command(cmd)

  File "C:\Python27\lib\distutils\dist.py", line 972, in run_command

    cmd_obj.run()

  File "build\bdist.win-amd64\egg\setuptools\command\install.py", line 53, in run

  File "C:\Python27\lib\distutils\command\install.py", line 563, in run

    self.run_command('build')

  File "C:\Python27\lib\distutils\cmd.py", line 326, in run_command

    self.distribution.run_command(command)

  File "C:\Python27\lib\distutils\dist.py", line 972, in run_command

    cmd_obj.run()

  File "C:\Python27\lib\distutils\command\build.py", line 127, in run

    self.run_command(cmd_name)

  File "C:\Python27\lib\distutils\cmd.py", line 326, in run_command

    self.distribution.run_command(command)

  File "C:\Python27\lib\distutils\dist.py", line 972, in run_command

    cmd_obj.run()

  File "build\bdist.win-amd64\egg\setuptools\command\build_ext.py", line 52, in run

  File "C:\Python27\lib\distutils\command\build_ext.py", line 337, in run

    self.build_extensions()

  File "C:\Python27\lib\distutils\command\build_ext.py", line 446, in build_extensions

    self.build_extension(ext)

  File "build\bdist.win-amd64\egg\setuptools\command\build_ext.py", line 186, in build_extension

  File "C:\Python27\lib\distutils\command\build_ext.py", line 496, in build_extension

    depends=ext.depends)

  File "C:\Python27\lib\distutils\msvc9compiler.py", line 473, in compile

    self.initialize()

  File "C:\Python27\lib\distutils\msvc9compiler.py", line 383, in initialize

    vc_env = query_vcvarsall(VERSION, plat_spec)

  File "C:\Python27\lib\distutils\msvc9compiler.py", line 299, in query_vcvarsall

    raise ValueError(str(list(result.keys())))

ValueError: [u'path']

----------------------------------------
Cleaning up...
  Removing temporary dir c:\users\t\appdata\local\temp\pip_build_T...
Command C:\Python27\python.exe -c "import setuptools, tokenize;__file__='c:\\users\\t\\appdata\\local\\temp\\pip_build_T\\MySQL-python\\setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record c:\users\t\appdata\local\temp\pip-d5hmns-record\install-record.txt --single-version-externally-managed --compile failed with error code 1 in c:\users\t\appdata\local\temp\pip_build_T\MySQL-python
Exception information:
Traceback (most recent call last):
  File "C:\Python27\lib\site-packages\pip-1.5.4-py2.7.egg\pip\basecommand.py", line 122, in main
    status = self.run(options, args)
  File "C:\Python27\lib\site-packages\pip-1.5.4-py2.7.egg\pip\commands\install.py", line 283, in run
    requirement_set.install(install_options, global_options, root=options.root_path)
  File "C:\Python27\lib\site-packages\pip-1.5.4-py2.7.egg\pip\req.py", line 1435, in install
    requirement.install(install_options, global_options, *args, **kwargs)
  File "C:\Python27\lib\site-packages\pip-1.5.4-py2.7.egg\pip\req.py", line 706, in install
    cwd=self.source_dir, filter_stdout=self._filter_install, show_stdout=False)
  File "C:\Python27\lib\site-packages\pip-1.5.4-py2.7.egg\pip\util.py", line 697, in call_subprocess
    % (command_desc, proc.returncode, cwd))
InstallationError: Command C:\Python27\python.exe -c "import setuptools, tokenize;__file__='c:\\users\\t\\appdata\\local\\temp\\pip_build_T\\MySQL-python\\setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record c:\users\t\appdata\local\temp\pip-d5hmns-record\install-record.txt --single-version-externally-managed --compile failed with error code 1 in c:\users\t\appdata\local\temp\pip_build_T\MySQL-python
回溯(最近一次呼叫最后一次):
文件“”,第1行,在
文件“c:\users\t\appdata\local\temp\pip\u build\u t\MySQL python\setup.py”,第21行,在
setuptools.setup(**元数据)
文件“C:\Python27\lib\distutils\core.py”,第152行,在安装程序中
dist.run_命令()
文件“C:\Python27\lib\distutils\dist.py”,第953行,在run\u命令中
self.run_命令(cmd)
文件“C:\Python27\lib\distutils\dist.py”,第972行,在run\u命令中
cmd_obj.run()
运行文件“build\bdist.win-amd64\egg\setuptools\command\install.py”,第53行
文件“C:\Python27\lib\distutils\command\install.py”,第563行,正在运行
self.run_命令('build'))
文件“C:\Python27\lib\distutils\cmd.py”,第326行,在run\u命令中
self.distribution.run_命令(command)
文件“C:\Python27\lib\distutils\dist.py”,第972行,在run\u命令中
cmd_obj.run()
文件“C:\Python27\lib\distutils\command\build.py”,第127行,正在运行
self.run_命令(cmd_名称)
文件“C:\Python27\lib\distutils\cmd.py”,第326行,在run\u命令中
self.distribution.run_命令(command)
文件“C:\Python27\lib\distutils\dist.py”,第972行,在run\u命令中
cmd_obj.run()
文件“build\bdist.win-amd64\egg\setuptools\command\build\u ext.py”,第52行,运行中
文件“C:\Python27\lib\distutils\command\build\u ext.py”,第337行,正在运行
self.build_扩展()
文件“C:\Python27\lib\distutils\command\build\u ext.py”,第446行,内部版本扩展名
自构建扩展(ext)
文件“build\bdist.win-amd64\egg\setuptools\command\build\u ext.py”,第186行,内部版本扩展名
文件“C:\Python27\lib\distutils\command\build\u ext.py”,第496行,内部版本扩展名
dependens=ext.dependens)
文件“C:\Python27\lib\distutils\msvc9compiler.py”,第473行,在compile中
self.initialize()
文件“C:\Python27\lib\distutils\msvc9compiler.py”,第383行,在初始化中
vc_env=query_vcvarsall(版本、平台规范)
文件“C:\Python27\lib\distutils\msvc9compiler.py”,第299行,位于查询\u vcvarsall中
提升值错误(str(list(result.keys()))
ValueError:[u'path']
----------------------------------------
清理。。。
正在删除临时目录c:\users\t\appdata\local\temp\pip\u build\t。。。
命令C:\Python27\python.exe-C“导入setuptools,tokenize;\uuuuu file\uuuuu='C:\\users\\t\\appdata\\local\\temp\\pip\u build\u t\\MySQL python\\setup.py';exec(编译(getattr(tokenize,'open',open)(\uuuu file\uuuu.).read().replace('\r\n','\n'),\uu file,'exec'))安装--记录c:\users\t\appdata\local\temp\pip-d5hmns-record\install-record.txt--外部管理的单一版本--在c:\users\t\appdata\local\temp\pip\u build\u t\MySQL python中编译失败,错误代码为1
例外信息:
回溯(最近一次呼叫最后一次):
文件“C:\Python27\lib\site packages\pip-1.5.4-py2.7.egg\pip\basecommand.py”,第122行,在main中
status=self.run(选项、参数)
文件“C:\Python27\lib\site packages\pip-1.5.4-py2.7.egg\pip\commands\install.py”,第283行,正在运行
需求设置.install(安装选项,全局选项,root=options.root路径)
安装中的第1435行文件“C:\Python27\lib\site packages\pip-1.5.4-py2.7.egg\pip\req.py”
要求.安装(安装选项、全局选项、*args、**kwargs)
文件“C:\Python27\lib\site packages\pip-1.5.4-py2.7.egg\pip\req.py”,第706行,在安装中
cwd=self.source\u dir,filter\u stdout=self.\u filter\u install,show\u stdout=False)
文件“C:\Python27\lib\site packages\pip-1.5.4-py2.7.egg\pip\util.py”,第697行,在call_子流程中
%(命令描述,过程返回代码,cwd))
安装错误:命令C:\Python27\python.exe-C“导入setuptools,tokenize;\uuuu文件\uuuuu='C:\\users\\t\\appdata\\local\\temp\\pip\u build\u t\\MySQL python\\setup.py';exec(编译(getattr(tokenize,'open',open)(\uuu文件\uuu).read().replace('\r\n','\n'),\uu文件,'exec')”安装--记录c:\users\t\appdata\local\temp\pip-d5hmns-record\install-record.txt--外部管理的单一版本--在c:\users\t\appdata\local\temp\pip\u build\u t\MySQL python中编译失败,错误代码为1

pip安装失败表明对已编译文件存在某种潜在的依赖性。另一种方法是从中使用.exe安装程序,但这不适用于virtualenvs,并且对于64位Python将失败(它会抱怨说,即使安装了Python 2.7,也无法在注册表中找到它)

幸运的是,Christoph Gohlke维护了一些非官方的Windows二进制文件,它们是pip可安装的。你可以在

现在可以从主python环境或VirtualEnvironment调用
pip install C:/PATH/TO/MySQL_python-1.2.5-cp27-none-win_amd64.whl

理想情况下,类似这样的控制盘将通过MySQL-python-PyPI页面提供,此时一个简单的
pip安装将起作用


(这个答案基于卡斯滕的有用评论。)

你是坚持自己安装一个工具链来编译它,还是只想安装它?如果是后者,请看一看并欣赏你在那里找到的Windows安装程序。谢谢你的快速回复。易居