I am trying to import MySQLdb in python. I checked and followed all possible solutions but I am still not able to import it. I have Windows 8.1.
我正在尝试用python导入MySQLdb。我检查了所有可能的解决方案,但是我仍然不能导入它。我有Windows 8.1。
So I started fresh, I installed the latest version of python (2.7.8), set the path and pythonpath variables, and then tried installing the MySQL-python-1.2.5.win-amd64-py2.7 from the link (https://pypi.python.org/pypi/MySQL-python/)
因此,我重新开始,安装了最新版本的python(2.7.8),设置了路径和python路径变量,然后尝试从链接(https://pypi.python.org/pypi/MySQL-python/)中安装MySQL-python-1.2.5.win-amd64-py2.7。
This is the error I get
这就是我得到的误差
>>> import MySQLdb
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named MySQLdb
I have tried searching and following many links. Nothing worked!! Can someone please help me with this.
我尝试搜索和跟踪许多链接。没有工作!有人能帮我吗?
Thanks
谢谢
1 个解决方案
#1
-1
Issue resolved. I dint have a C compiler / Visual Studio in my laptop - This link might help http://mysql-python.blogspot.com/2012/11/is-mysqldb-hard-to-install.html I installed MinGW - http://sourceforge.net/projects/mingw/?source=typ_redirect Selected the c++ option
问题解决。我的笔记本上有一个C编译器/ Visual Studio——这个链接可能会对我安装的MinGW - http://sourceforge.net/projects/mingw/?source=typ_redirect选择c++选项
I uninstalled Anaconda, Python and Installed anaconda again. So python 2.7.7 got installed along with Anaconda. Did a conda init,
我卸载了蟒蛇,又安装了蟒蛇。所以python 2。7和Anaconda一起安装。做了一个conda init,
conda install pip
pip install mysql-python
and then import MySQLdb
然后导入MySQLdb
No Error!! Hope this helps!!
没有错误!希望这有助于! !
====================================================================
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
Update - Jan 2, 2015
更新- 2015年1月2日
If you want to try installing mysql-python package using conda instead of pip, you can try the following, which worked for me.
如果您想尝试使用conda而不是pip来安装mysql-python包,您可以尝试以下方法,这对我来说是有效的。
conda install binstar
binstar search -t conda mysql-python
This will show you 10 different packages for different OS. krisvanneste mysql-python is for Win-64
这将向您展示不同OS的10个不同的包。krisvanneste mysql-python是Win-64
To know more about this package use the command
要了解更多有关此包的信息,请使用该命令。
binstar show krisvanneste/mysql-python
This will show you the command to install the mysql-python package which happens to be
这将向您展示安装mysql-python包的命令
conda install --channel https://conda.binstar.org/krisvanneste mysql-python
This will install the required package. Now trying import MySQLdb in python wont throw error.
这将安装所需的包。现在在python中尝试导入MySQLdb不会抛出错误。
#1
-1
Issue resolved. I dint have a C compiler / Visual Studio in my laptop - This link might help http://mysql-python.blogspot.com/2012/11/is-mysqldb-hard-to-install.html I installed MinGW - http://sourceforge.net/projects/mingw/?source=typ_redirect Selected the c++ option
问题解决。我的笔记本上有一个C编译器/ Visual Studio——这个链接可能会对我安装的MinGW - http://sourceforge.net/projects/mingw/?source=typ_redirect选择c++选项
I uninstalled Anaconda, Python and Installed anaconda again. So python 2.7.7 got installed along with Anaconda. Did a conda init,
我卸载了蟒蛇,又安装了蟒蛇。所以python 2。7和Anaconda一起安装。做了一个conda init,
conda install pip
pip install mysql-python
and then import MySQLdb
然后导入MySQLdb
No Error!! Hope this helps!!
没有错误!希望这有助于! !
====================================================================
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
Update - Jan 2, 2015
更新- 2015年1月2日
If you want to try installing mysql-python package using conda instead of pip, you can try the following, which worked for me.
如果您想尝试使用conda而不是pip来安装mysql-python包,您可以尝试以下方法,这对我来说是有效的。
conda install binstar
binstar search -t conda mysql-python
This will show you 10 different packages for different OS. krisvanneste mysql-python is for Win-64
这将向您展示不同OS的10个不同的包。krisvanneste mysql-python是Win-64
To know more about this package use the command
要了解更多有关此包的信息,请使用该命令。
binstar show krisvanneste/mysql-python
This will show you the command to install the mysql-python package which happens to be
这将向您展示安装mysql-python包的命令
conda install --channel https://conda.binstar.org/krisvanneste mysql-python
This will install the required package. Now trying import MySQLdb in python wont throw error.
这将安装所需的包。现在在python中尝试导入MySQLdb不会抛出错误。