mysql-python 的构建轮失败
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/43426780/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Failed building wheel for mysql-python
提问by Swathi Pantala
I want to run a Django application in PyCharm which works on MySQL DB.
我想在 PyCharm 中运行一个适用于 MySQL DB 的 Django 应用程序。
I am unable to connect my program to the database.
我无法将我的程序连接到数据库。
When I am trying to install MySQLclient or MySQL-python I am getting the error:
当我尝试安装 MySQLclient 或 MySQL-python 时,出现错误:
Failed building wheel for MySQLclient
MySQLclient 的构建轮失败
Please help me out in connecting my Django program with MySQL database.
请帮助我将我的 Django 程序与 MySQL 数据库连接起来。
回答by Gaurav Vasudev
Edit
编辑
Please try installing the .whl file from http://www.lfd.uci.edu/~gohlke/pythonlibs/. This works every time. Just type pip install MySQL_python?1.2.5?cp27?none?win32.whl
in the terminal.
请尝试从http://www.lfd.uci.edu/~gohlke/pythonlibs/安装 .whl 文件。这每次都有效。只需pip install MySQL_python?1.2.5?cp27?none?win32.whl
在终端中输入即可。
Original Answer
原答案
I had the same issue. You might find these steps helpful.
我遇到过同样的问题。您可能会发现这些步骤很有帮助。
- Make sure you are in an activated virtualenv when you are installing anything through pip.
- Before you install anything, type
pip list
in the terminal to see what you have installed in the virtualenv. It should have wheel, setuptools and pip. - This is the part that helped me, type
pip install mysqlclient==1.3.9
or whatever version you want to install. This needs to happen before you install django. - Hopefully, it works and you can go ahead and install Django.
- 当您通过 pip 安装任何东西时,请确保您处于激活的 virtualenv 中。
- 在安装任何东西之前,请
pip list
在终端中输入以查看您在 virtualenv 中安装的内容。它应该有轮子、设置工具和 pip。 - 这是帮助我的部分,键入
pip install mysqlclient==1.3.9
或您要安装的任何版本。这需要在安装 django 之前发生。 - 希望它可以工作,您可以继续安装 Django。
If these steps didn't work out for you, try installing MySQL-Python through the executable file here https://pypi.python.org/pypi/MySQL-python/1.2.5.
如果这些步骤对您不起作用,请尝试通过https://pypi.python.org/pypi/MySQL-python/1.2.5 中的可执行文件安装 MySQL-Python 。
But this will only install mysql-python for you in the system. You can try pip list
outside virtualenv to see if mysql-python is installed. If it is installed, then you have update this post so we can figure out a solution.
但这只会在系统中为您安装 mysql-python。您可以尝试pip list
在 virtualenv 之外查看是否安装了 mysql-python。如果已安装,则您已更新此帖子,以便我们找出解决方案。
In the meantime some other fixes are:
与此同时,其他一些修复是:
- Can't install mysql-python (newer versions) in Windows
- Install Visual C++ for Python and add the bin folder to the PATH environment variable.
- Make sure the mysql service is running in the background or is installed in your system by running mysql commands through the terminal.
- Sometimes, two different instances of mysql service might cause this error i.e. if you have installed mysql server or any other product multiple times in the past, you might have to get rid of the ports the past services used. In this case, do a fresh installation of mysql server and add the ~\bin path to the PATH environment variable.
- 无法在 Windows 中安装 mysql-python(较新版本)
- 安装 Visual C++ for Python 并将 bin 文件夹添加到 PATH 环境变量。
- 通过终端运行 mysql 命令,确保 mysql 服务在后台运行或安装在您的系统中。
- 有时,mysql 服务的两个不同实例可能会导致此错误,即如果您过去曾多次安装 mysql 服务器或任何其他产品,您可能必须摆脱过去服务使用的端口。在这种情况下,请重新安装 mysql 服务器并将 ~\bin 路径添加到 PATH 环境变量中。
回答by Shamsul Arefin Sajib
I had the same problem. I then uninstalled my python. Downloaded the python 3.6.5. then used a command from
我有同样的问题。然后我卸载了我的python。下载了python 3.6.5。然后使用来自的命令
Python 3.7, Failed building wheel for MySql-Python
Python 3.7,MySql-Python 的构建轮失败
the command is pip install mysqlclient==1.3.12
命令是 pip install mysqlclient==1.3.12