如何在Anaconda的Python IDE中使用MySQL [英] How to use MySQL with Anaconda's Python IDE

查看:292
本文介绍了如何在Anaconda的Python IDE中使用MySQL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只希望能够执行一个简单的SELECT * FROM查询.

I just want to be able to do a simple SELECT * FROM query.

我找到了Python MySQLdb软件包,但无法使用Windows安装程序进行安装.它说,

I found a Python MySQLdb Package, but can't get it to install using the Windows installer. It says,

在注册表中找不到Python

Python is not found in the registry

然后我尝试简短地自己进行编译,但是到目前为止,我已经在编译过程中调试了大约六个错误,并且放弃了.

I then tried briefly to compile it myself but I've debugged about six errors so far during the compile process and have given up.

如果您能够使用 Anaconda 连接到MySQL,能否请您详细说明您的操作方式?谢谢.

If you are able to connect to MySQL using Anaconda, could you please detail out how you did it? Thanks.

推荐答案

问题是Python软件包的二进制安装程序正在寻找特定的注册表项,如果您正在使用Anaconda安装程序,则该注册表项将不存在.

The problem is that the binary installers for Python packages are looking for a specific registry key, which does not exist if you are using the Anaconda installer.

更糟糕的是,Anaconda不在其商业或免费存储库中提供数据库驱动程序.

To make matters worse, Anaconda doesn't provide database drivers in either their commercial or free repository.

所以现在您有两个选择

  1. 推荐-摆脱Anaconda.卸载它.使用 Windows专用Python安装程序安装Python.目前,我建议使用2.7.x系列以获得最大的兼容性.要使原始安装与Anaconda相同,可以安装与Anaconda捆绑在一起的软件包分开.

  1. Recommended - get rid of Anaconda. Uninstall it. Install Python using the official Python installer for Windows. At this time, I would recommend the 2.7.x series for maximum compatibility. To make your vanilla installation the same as Anaconda, you can install the packages that are bundled with Anaconda separately.

加州大学欧文分校的荧光动力学实验室维护着一个 Python软件包的存储库很难在Windows上安装.他们已将这些软件包转换为Windows安装程序二进制文件.因此,只需下载并双击即可安装.就像MySQL安装程序一样,它们也只能与官方的Python安装程序一起使用.出于同样的原因.

The Laboratory for Fluorescence Dynamics at the University of California, Irvine maintains a repository of Python packages that are difficult to install on Windows. They have taken these packages and converted them into Windows installer binaries. So, simply download and double click to install. Just like the MySQL installer, these will also only work with the official Python installer; for the same reason.

您可能需要的主要软件包,可以通过安装以下软件开始:

The main packages you are probably after, you can start by installing the following:

  1. setuptools
  2. ipython
  3. numpy
  4. scipy
  5. pandas
  6. matplotlib 要求:
  1. setuptools
  2. ipython
  3. numpy
  4. scipy
  5. pandas
  6. matplotlib requires:
  1. dateutil
  2. pytz
  3. pyparsing
  4. six
  5. Pillow
  6. pycairo
  7. tornado
  1. dateutil
  2. pytz
  3. pyparsing
  4. six
  5. Pillow
  6. pycairo
  7. tornado
  1. certifi
  2. backports

  • wx-python
  • pyside
  • pyqt
  • wx-python
  • pyside
  • pyqt
  • Numba

  • Numba

    1. llvm

  • blaze
  • bokeh
  • blaze
  • bokeh
  • 下载这些文件需要一些时间,但是它们都是Windows安装程序,因此您只需双击它们即可.请记住先决条件(上面缩进的条目).

    It will take some time to download these, but they are all Windows installers so you just have to double click your way through them. Keep in mind the pre-requisites (indented entries above).

    另一个选择是欺骗MySQL安装程序(和其他Windows安装程序),使其认为Anaconda安装是官方的Python安装.您可以通过修改注册表来做到这一点.

    The other option is to trick the MySQL installer (and other Windows installers) into thinking the Anaconda installation is the official Python installation. You can do that by modifying the registry.

    对于Windows 7 64,使用以下命令创建文件:

    For Windows 7 64, create a file with the following:

    Windows Registry Editor Version 5.00
    
    [HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Python\PythonCore\2.7\InstallPath]
    @="D:\\Python27\\"
    

    "D:\\Python27\\"替换为Anaconda安装的路径.用.reg扩展名保存上述文件,然后双击它以影响对注册表的更改.为此,可能需要管理员级别的访问权限,因此上述内容可能不适用于您的系统.

    Replace "D:\\Python27\\" with the path to your Anaconda installation. Save the above file with a .reg extension, then double click it to affect the changes to your registry. To do this might require administrator level access so the above might not work for your system.

    我强烈建议您选择选项#1,因为它可以确保您的系统设置为与其他Python库最兼容.

    I would highly recommend option #1 because it will ensure your system is setup to be most compatible with other Python libraries.

    这篇关于如何在Anaconda的Python IDE中使用MySQL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆