Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/macos/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Can';t在MacOS 10.12.4上安装带pip的mysql python_Python_Macos_Pip - Fatal编程技术网

Can';t在MacOS 10.12.4上安装带pip的mysql python

Can';t在MacOS 10.12.4上安装带pip的mysql python,python,macos,pip,Python,Macos,Pip,运行pip安装mysql python时收到以下错误 Collecting mysql-python Using cached MySQL-python-1.2.5.zip Complete output from command python setup.py egg_info: Traceback (most recent call last): File "<string>", line 1, in <module> Fi

运行
pip安装mysql python时收到以下错误

Collecting mysql-python
  Using cached MySQL-python-1.2.5.zip
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/private/var/folders/b_/xh05hxwd0lzc3rm858jsypdc0000gn/T/pip-build-AWDYaP/mysql-python/setup.py", line 17, in <module>
        metadata, options = get_config()
      File "setup_posix.py", line 53, in get_config
        libraries = [ dequote(i[2:]) for i in libs if i.startswith(compiler_flag("l")) ]
      File "setup_posix.py", line 8, in dequote
        if s[0] in "\"'" and s[0] == s[-1]:
    IndexError: string index out of range

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/b_/xh05hxwd0lzc3rm858jsypdc0000gn/T/pip-build-AWDYaP/mysql-python/
此错误似乎是在安装MacOS 10.12.4更新后发生的,已通过此解决

brew install mysql
pip install MySQL-python

如果你和我一样,在mac上从源代码安装了mysql,那么忘记建议谁使用brew——你的机器已经有了mysql-connector-c。如果确实是brew安装了mysql-connector-c,请执行brew卸载mysql-connector-c并再次尝试pip安装mysql python(python 3)。

如果仍然出现类似“为mysql python构建轮子失败”的问题,请尝试

这对我来说很有魅力。

这对我来说很有用:

    brew install mysql@5.7
    brew link --force mysql@5.7
这对我很有用(macOS Mojave 10.14.2):


要解决这个问题,我们应该编辑mysql\u配置文件

为此,发出以下命令:

vi `which mysql_config`
这将在vi编辑器中打开
mysql\u config

i
进入插入模式

现在找到线

# Create options 
libs="-L$pkglibdir"
libs="$libs -l "
对我来说,它在118号线上。上述行应更改为

# Create options 
libs="-L$pkglibdir"
libs="$libs -lmysqlclient -lssl -lcrypto"
现在按
esc
按钮退出插入模式并保存添加的内容 通过在vi编辑器中发出命令
:wq

现在尝试使用pip重新安装
MySQL-Python
模块

注意:假设为我安装了
mysql
openssl

,这是有效的:

brew install mysql-connector-c 
pip install MySQL-python
pip install mysql-connector

谢谢你的解决方案。这让我快发疯了。实际上,我必须同时完成您和其他人的操作:brew取消mysql-connector-c链接,然后brew安装mysql添加一个
brew链接mysql
,然后^I确保mysql已安装并链接,然后运行pip安装mysql python,仍然是相同的错误谢谢!节省了我很多时间!杰出的非常感谢你!也为我节省了几个小时:)这是唯一对我有效的解决方案,非常感谢!!也救了我一天。也救了我的期末作业。谢谢!这就是我的工作。还和莫哈韦打交道。谢谢,节省了我很多时间。在macOS Mojave工作。这个解决方案是唯一对我有效的。非常感谢。
# Create options 
libs="-L$pkglibdir"
libs="$libs -l "
# Create options 
libs="-L$pkglibdir"
libs="$libs -lmysqlclient -lssl -lcrypto"
brew install mysql-connector-c 
pip install MySQL-python
pip install mysql-connector