7

我正在尝试在我的 virtualenv(Windows 7 32b + Python 2.7.3)中安装 MySQL-python,但不幸的是在命令之后:

pip install MySQL-python

我收到错误消息:

Install packages failed: Error occurred when installing package MySQL-python. 

The following command was executed:

packaging_tool.py install --build-dir C:\Users\Grzegorz\AppData\Local\Temp\pycharm-packaging3577041299153334552.tmp MySQL-python

The error output of the command:


Downloading/unpacking MySQL-python
  Running setup.py egg_info for package MySQL-python
Traceback (most recent call last):
  File "<string>", line 16, in <module>
  File "C:\Users\Grzegorz\AppData\Local\Temp\pycharm-packaging3577041299153334552.tmp\MySQL-python\setup.py", line 15, in <module>
    metadata, options = get_config()
  File "setup_windows.py", line 7, in get_config
    serverKey = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, options['registry_key'])
WindowsError: [Error 2] Nie można odnaleźć określonego pliku
Complete output from command python setup.py egg_info:
Traceback (most recent call last):

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

File "C:\Users\Grzegorz\AppData\Local\Temp\pycharm-packaging3577041299153334552.tmp\MySQL-python\setup.py", line 15, in <module>

metadata, options = get_config()

File "setup_windows.py", line 7, in get_config

serverKey = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, options['registry_key'])

WindowsError: [Error 2] Nie można odnaleźć określonego pliku

----------------------------------------
Command python setup.py egg_info failed with error code 1 in C:\Users\Grzegorz\AppData\Local\Temp\pycharm-packaging3577041299153334552.tmp\MySQL-python
Storing complete log in C:\Users\Grzegorz\pip\pip.log

如果我尝试从二进制 MySQL-python-1.2.3.win32-py2.7.exe 安装这个包,那么一切都会正确安装,但这对我来说不是解决方案。您对如何在 Windows 7 上正确安装此软件包有任何建议(我可以毫无问题地安装所有其他软件包)?

4

3 回答 3

22

您是否尝试过使用:

 easy_install MySQL-python

它适用于我在 Windows 7 中使用 Virtualenv 很长的时间。我对 pip 有同样的问题。

于 2013-03-04T19:17:40.933 回答
11

如果您可以从http://www.lfd.uci.edu/~gohlke/pythonlibs/#mysql-python全局安装 mysql-python(在 C:/python27 中)

然后您可以将以下文件从“C:/python/lib/site-packages”复制粘贴到您的虚拟环境“/lib/site-packages”

  1. MySQL_python-1.2.4-py2.7.egg-info(文件夹)
  2. MySQLdb(文件夹)
  3. _mysql_exceptions.py/.pyc/.pyo
  4. _mysql.pyd

**不需要从 "C:\Python27\Lib\site-packages\django\db\backends" 或 "C:\Python27\Lib\site-packages\django\contrib\gis\db\ 复制 mysql 文件后端”。

于 2013-11-20T09:54:50.240 回答
1

SourceForge 现在有一个Windows MSI 安装程序。试试看,但如果你现在更愿意自己构建(直到 1.2.4 发布),你应该可以这样做:

pip install http://svn.code.sf.net/p/mysql-python/svn/branches/MySQLdb-1.2/MySQLdb

以上假设您已安装 Subversion。

于 2012-09-20T20:30:20.587 回答