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

查看:81
本文介绍了如何在 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 系列以获得最大的兼容性.要使您的 vanilla 安装与 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. dateutil
  2. pytz
  3. pyparsing
  4. 枕头
  5. pycairo
  6. 龙卷风
  1. certifi
  2. backports

  • wx-python
  • pyside
  • pyqt
  • Numba

    1. llvm

  • 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_MACHINESOFTWAREWow6432NodePythonPythonCore2.7InstallPath]
    @="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天全站免登陆