【问题标题】:How can I fix this error very time I try type pip install mysql-python每次我尝试输入 pip install mysql-python 时如何解决这个错误
【发布时间】:2019-08-18 12:12:10
【问题描述】:

我一直在尝试在 mac 上安装 python-MySQLdb,但一直出错。我已经尝试了很多替代方法来传递该错误。

sudo PATH=/usr/local/Cellar/mysql/bin/:$PATH pip install mysql-python
Password:
DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7.
The directory '/Users/zuhairhallak/Library/Caches/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/Users/zuhairhallak/Library/Caches/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Collecting mysql-python
  Downloading https://files.pythonhosted.org/packages/a5/e9/51b544da85a36a68debe7a7091f068d802fc515a3a202652828c73453cad/MySQL-python-1.2.5.zip (108kB)
    100% |████████████████████████████████| 112kB 2.6MB/s 
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/private/tmp/pip-install-RtF2js/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/tmp/pip-install-RtF2js/mysql-python/

我也运行了 sudo -H pip install mysql-python 并且得到了不同的错误

生成了 13 条警告。 cc -bundle -undefined dynamic_lookup -Wl,-F。 build/temp.macosx-10.14-intel-2.7/_mysql.o -L/usr/local/Cellar/mysql/8.0.15/lib -lmysqlclient -lssl -lcrypto -o build/lib.macosx-10.14-intel-2.7 /_mysql.so ld:找不到 -lssl 的库 clang:错误:链接器命令失败,退出代码为 1(使用 -v 查看调用) 错误:命令“cc”失败,退出状态为 1


mysql-python 构建轮子失败 为 mysql-python 运行 setup.py clean 无法构建 mysql-python 安装收集的包:mysql-python 为 mysql-python 运行 setup.py install ... 错误 命令的完整输出 /usr/bin/python -u -c "import setuptools, tokenize;file='/private/tmp/pip-install-3A8kOd/mysql-python/setup.py'; f=getattr(tokenize, 'open', open)(file);code=f.read().replace('\r\n', '\n');f.close( );exec(compile(code, file, 'exec'))" install --record /private/tmp/pip-record-TUb4up/install-record.txt --single-version-externally -托管--编译

【问题讨论】:

标签: python mysql homebrew


【解决方案1】:

请尝试

brew install mysql
sudo -H pip install mysql-python

【讨论】:

  • 您能否添加更多详细信息,说明问题所在以及如何解决?这将有助于理解 OP 和未来的读者。
  • 命令 "/usr/bin/python -u -c "import setuptools, tokenize;__file__='/private/tmp/pip-install-3A8kOd/mysql-python/setup.py';f =getattr(tokenize, 'open', open)(file);code=f.read().replace('\r\n', '\n');f.close() ;exec(compile(code, file, 'exec'))" install --record /private/tmp/pip-record-TUb4up/install-record.txt --single-version-externally- managed --compile" 失败,错误代码 1 在 /private/tmp/pip-install-3A8kOd/mysql-python/
  • 运行 sudo -H pip install mysql-python 后出现另一个错误
【解决方案2】:

我打开了mysql_config文件

vi mysql_config

这是正确的。

Create options:
Libs = "- L $ pkglibdir"
Libs = "$ libs -lmysqlclient -lssl -lcrypto"

在终端运行此命令 1.导出LDFLAGS="-L/usr/local/opt/openssl/lib" 2.导出CPPFLAGS="-I/usr/local/opt/openssl/include" 3. pip install mysql-python

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-03-31
    • 1970-01-01
    • 2021-10-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-06
    • 1970-01-01
    相关资源
    最近更新 更多