imac不认mysql命令_mysql-python - 在osx 10.8上安装mysql-python时找不到“ my_config.h”文件 - 堆栈内存溢出...

我使用brew在Mac OS 10.14.2上安装了所有程序。

当在Mojave上的虚拟环境( virtualenv )内时,其他答案对我不起作用。 我按照Jofsey的指示进行操作,但出现错误:

# define SIZEOF_LONG 4

^

In file included from _mysql.c:44:

/usr/local/include/my_config.h:179:9: warning: 'SIZEOF_TIME_T' macro redefined [-Wmacro-redefined]

#define SIZEOF_TIME_T 8

^

/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/pymacconfig.h:57:17: note: previous definition is here

# define SIZEOF_TIME_T 4

^

2 warnings generated.

_mysql.c:287:14: warning: implicit conversion loses integer precision: 'Py_ssize_t' (aka 'long') to 'int' [-Wshorten-64-to-32]

cmd_argc = PySequence_Size(cmd_args);

~ ^~~~~~~~~~~~~~~~~~~~~~~~~

_mysql.c:317:12: warning: implicit conversion loses integer precision: 'Py_ssize_t' (aka 'long') to 'int' [-Wshorten-64-to-32]

groupc = PySequence_Size(groups);

~ ^~~~~~~~~~~~~~~~~~~~~~~

_mysql.c:470:14: warning: implicit conversion loses integer precision: 'Py_ssize_t' (aka 'long') to 'int' [-Wshorten-64-to-32]

int j, n2=PySequence_Size(fun);

~~ ^~~~~~~~~~~~~~~~~~~~

_mysql.c:1127:9: warning: implicit conversion loses integer precision: 'unsigned long' to 'int' [-Wshorten-64-to-32]

len = mysql_real_escape_string(&(self->connection), out, in, size);

~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

_mysql.c:1129:9: warning: implicit conversion loses integer precision: 'unsigned long' to 'int' [-Wshorten-64-to-32]

len = mysql_escape_string(out, in, size);

~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

_mysql.c:1168:9: warning: implicit conversion loses integer precision: 'Py_ssize_t' (aka 'long') to 'int' [-Wshorten-64-to-32]

size = PyString_GET_SIZE(s);

~ ^~~~~~~~~~~~~~~~~~~~

/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/stringobject.h:92:32: note: expanded from macro 'PyString_GET_SIZE'

#define PyString_GET_SIZE(op) Py_SIZE(op)

^~~~~~~~~~~

/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/object.h:116:56: note: expanded from macro 'Py_SIZE'

#define Py_SIZE(ob) (((PyVarObject*)(ob))->ob_size)

~~~~~~~~~~~~~~~~~~~~~~^~~~~~~

_mysql.c:1178:9: warning: implicit conversion loses integer precision: 'unsigned long' to 'int' [-Wshorten-64-to-32]

len = mysql_real_escape_string(&(self->connection), out+1, in, size);

~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

_mysql.c:1180:9: warning: implicit conversion loses integer precision: 'unsigned long' to 'int' [-Wshorten-64-to-32]

len = mysql_escape_string(out+1, in, size);

~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

_mysql.c:1274:11: warning: implicit conversion loses integer precision: 'Py_ssize_t' (aka 'long') to 'int' [-Wshorten-64-to-32]

if ((n = PyObject_Length(o)) == -1) goto error;

~ ^~~~~~~~~~~~~~~~~~

/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/abstract.h:434:25: note: expanded from macro 'PyObject_Length'

#define PyObject_Length PyObject_Size

^

_mysql.c:1466:10: warning: implicit conversion loses integer precision: 'unsigned long' to 'int' [-Wshorten-64-to-32]

len = strlen(buf);

~ ^~~~~~~~~~~

_mysql.c:1468:10: warning: implicit conversion loses integer precision: 'unsigned long' to 'int' [-Wshorten-64-to-32]

len = strlen(buf);

~ ^~~~~~~~~~~

_mysql.c:1504:11: warning: implicit conversion loses integer precision: 'unsigned long' to 'int' [-Wshorten-64-to-32]

len = strlen(buf);

~ ^~~~~~~~~~~

_mysql.c:1506:11: warning: implicit conversion loses integer precision: 'unsigned long' to 'int' [-Wshorten-64-to-32]

len = strlen(buf);

~ ^~~~~~~~~~~

13 warnings generated.

cc -bundle -undefined dynamic_lookup -Wl,-F. build/temp.macosx-10.14-intel-2.7/_mysql.o -L/usr/local/Cellar/mysql-connector-c/6.1.11/lib -lmysqlclient -lssl -lcrypto -o build/lib.macosx-10.14-intel-2.7/_mysql.so

ld: library not found for -lssl

clang: error: linker command failed with exit code 1 (use -v to see invocation)

error: command 'cc' failed with exit status 1

因此,在我运行了这些命令之后,我将其作为最终命令运行了,并且有效:

sudo pip install MySQL-Python --global-option=build_ext --global-option="-I/usr/local/opt/openssl/include" --global-option="-L/usr/local/opt/openssl/lib"

编辑:

我在GitHub上找到的另一个解决方案,假设您已经运行brew install openssl (它避免了CLI参数的需要,并且可以防止将来出现SSL库错误):

export LIBRARY_PATH=$LIBRARY_PATH:/usr/local/opt/openssl/lib/

您可以将上述内容放入~/.bash_profile文件中,然后运行source ~/.bash_profile或者如果它是虚拟环境,则可以找到一种在虚拟环境shell中运行导出并在虚拟环境CLI中检查值的方法。与echo $LIBRARY_PATH 。 设置$LIBRARY_PATH ,您将不会再看到这些SSL库错误。

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值