简体   繁体   English

在Windows 7的virtualenv中安装MySQL-python

[英]Install MySQL-python in virtualenv on Windows 7

I'm trying to install MySQL-python in my virtualenv (Windows 7 32b + Python 2.7.3), but unfortunately after command: 我正在尝试在我的virtualenv(Windows 7 32b + Python 2.7.3)中安装MySQL-python,但是不幸的是在命令之后:

pip install MySQL-python

I get error message: 我收到错误消息:

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

If I try to install this package from binary MySQL-python-1.2.3.win32-py2.7.exe then everything install properly, but it's not solution for me. 如果我尝试从二进制MySQL-python-1.2.3.win32-py2.7.exe安装此软件包,那么一切都将正确安装,但这对我来说不是解决方案。 Do you have any suggestions how can I properly install this package on Windows 7 (all other packages I'm able to install without any problems)? 您对我如何在Windows 7上正确安装此软件包有什么建议(我可以无问题安装所有其他软件包)?

Did you try using : 您是否尝试使用:

 easy_install MySQL-python

It works for me in Windows 7 a long with Virtualenv. 在Windows 7中,Virtualenv可以长时间为我工作。 I had the same problem with pip. 我在点子上也有同样的问题。

If you can install mysql-python globally (in C:/python27) from http://www.lfd.uci.edu/~gohlke/pythonlibs/#mysql-python 如果可以从http://www.lfd.uci.edu/~gohlke/pythonlibs/#mysql-python全局(在C:/ python27中)安装mysql-python

then you can copy paste the following files from "C:/python/lib/site-packages" to your virtual environment "/lib/site-packages" 那么您可以将以下文件从“ C:/ python / lib / site-packages”复制粘贴到您的虚拟环境“ / lib / site-packages”

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

**Don't need to copy mysql files from "C:\\Python27\\Lib\\site-packages\\django\\db\\backends" or "C:\\Python27\\Lib\\site-packages\\django\\contrib\\gis\\db\\backends". **无需从“ C:\\ Python27 \\ Lib \\ site-packages \\ django \\ db \\ backends”或“ C:\\ Python27 \\ Lib \\ site-packages \\ django \\ contrib \\ gis \\ db \\”中复制mysql文件后端”。

There is a Windows MSI installer now on SourceForge. SourceForge上现在有Windows MSI安装程序 Try that, but if you'd rather build your own, for now (until 1.2.4 is released), you should be able to do this: 尝试一下,但是如果您现在想要构建自己的(直到1.2.4发布),您应该可以这样做:

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

The above assumes you have Subversion installed. 以上假设您已安装Subversion。

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

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