anacoda2如何连接使用mysql,如何在Anaconda的Python IDE中使用MySQL

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

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

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.

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

解决方案

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.

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

So now you have two options

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.

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:

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).

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.

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\\"

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.

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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值