I have been beating my head against a wall on this for 2+ days and am making no progress.
I am trying to install the Python MySQL connectors on my Windows 8 (hate Windows 8) box.
I am using Python 2.7. I originally received an error:
vcvarsall.bat is not found.
I did some research and found that I needed VS 2008 (VC++ compiler) installed on my box and I installed the express version. I also added ProductDir value with the path to vcvarsall.bat to the following key in my registry:
HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\Microsoft\\VisualStudio\\9.0\\Setup\\VC.
I also added the VS90COMNTOOLS environment variable with the path to vcvarsall.bat. I am still getting an error when I run the following:
pip install MySQL-python
Any input you can provide is most appreciated... Thanks...
The error is listed in the following snippet from the 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
The pip install
failure suggests there is some underlying dependency on compiled files. An alternative would be to use the .exe installer from https://pypi.python.org/pypi/MySQL-python - but this isn't suitable for virtualenvs, and will fail for 64-bit Python (it will complain that it can't find Python 2.7 in the registry even though it is installed).
Luckily, Christoph Gohlke maintains some unofficial Windows binaries which are pip-installable. You can find them at at http://www.lfd.uci.edu/~gohlke/pythonlibs/#mysql-python
You can now call pip install C:/PATH/TO/MySQL_python‑1.2.5‑cp27‑none‑win_amd64.whl
from your main Python environment, or a virtualenv.
Ideally, wheels like these will be made available via the MySQL-python PyPI page, at which point a simple pip install
will work.
(This answer is based on Carsten
's helpful comments.)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.