安装mysqldb python界面时找不到mysql_config

发布于 2024-12-05 12:12:05 字数 756 浏览 1 评论 0原文

我正在尝试让 Python 脚本在我通过 ssh 连接的 Linux 服务器上运行。该脚本使用 mysqldb。我拥有所需的所有其他组件,但是当我尝试通过 setuptools 安装 mySQLdb 时,如下所示:,

python setup.py install

我收到以下与 mysql_config 命令相关的错误报告。

sh: mysql_config: command not found
Traceback (most recent call last):
  File "setup.py", line 15, in <module>
    metadata, options = get_config()
  File "/usr/lib/python2.5/MySQL-python-1.2.3/setup_posix.py", line 43, in get_config
    libs = mysql_config("libs_r")
  File "/usr/lib/python2.5/MySQL-python-1.2.3/setup_posix.py", line 24, in mysql_config
    raise EnvironmentError("%s not found" % (mysql_config.path,))
EnvironmentError: mysql_config not found

有其他人遇到过这个错误吗?如果是的话,你是如何解决它的/我该怎么做才能成功安装 mysqldb?

I am trying to get a Python script to run on the linux server I'm connected to via ssh. The script uses mysqldb. I have all the other components I need, but when I try to install mySQLdb via setuptools like so:,

python setup.py install

I get the following error report related to the mysql_config command.

sh: mysql_config: command not found
Traceback (most recent call last):
  File "setup.py", line 15, in <module>
    metadata, options = get_config()
  File "/usr/lib/python2.5/MySQL-python-1.2.3/setup_posix.py", line 43, in get_config
    libs = mysql_config("libs_r")
  File "/usr/lib/python2.5/MySQL-python-1.2.3/setup_posix.py", line 24, in mysql_config
    raise EnvironmentError("%s not found" % (mysql_config.path,))
EnvironmentError: mysql_config not found

Has anyone else encountered this error and if so how did you resolve it/what can I do to successfully install mysqldb?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(30

寒江雪… 2024-12-12 12:12:06

在 python 3.5.2 + 任何未来版本上

sudo apt-get install libmysqlclient-dev python-dev

On python 3.5.2 + any future version

sudo apt-get install libmysqlclient-dev python-dev

风透绣罗衣 2024-12-12 12:12:06

以下内容在 Ubuntu 12.04 LTS 上对我有用:

apt-get install libmysqlclient-dev python-dev

尽管它有效,但我仍然继续执行以下操作:

export PATH=$PATH:/usr/local/mysql/bin/

The below worked for me on Ubuntu 12.04 LTS:

apt-get install libmysqlclient-dev python-dev

All though it worked, i still went ahead to do the below:

export PATH=$PATH:/usr/local/mysql/bin/
半仙 2024-12-12 12:12:06

我在尝试安装 mysql-python 时遇到了同样的错误。

我就是这样解决的。

sudo PATH=/usr/local/mysql/bin/:$PATH pip install mysql-python

问题是安装程序在默认路径中找不到 mysql_config。现在它可以..并且有效..

 15 warnings generated.
    clang -bundle -undefined dynamic_lookup -Wl,-F. build/temp.macosx-10.8-intel-2.7/_mysql.o -L/usr/local/mysql/lib -lmysqlclient_r -lz -lm -lmygcc -o build/lib.macosx-10.8-intel-2.7/_mysql.so -arch x86_64

Successfully installed mysql-python
Cleaning up...

希望这会有所帮助。

谢谢。

I got the same error while trying to install mysql-python.

This is how I fixed it.

sudo PATH=/usr/local/mysql/bin/:$PATH pip install mysql-python

The problem was that the installer could not find the mysql_config in the default path. Now it can ..and it worked..

 15 warnings generated.
    clang -bundle -undefined dynamic_lookup -Wl,-F. build/temp.macosx-10.8-intel-2.7/_mysql.o -L/usr/local/mysql/lib -lmysqlclient_r -lz -lm -lmygcc -o build/lib.macosx-10.8-intel-2.7/_mysql.so -arch x86_64

Successfully installed mysql-python
Cleaning up...

Hope this helps.

Thanks.

太傻旳人生 2024-12-12 12:12:06

我通过以下步骤解决了这个问题:

sudo apt-get install libmysqlclient-dev
sudo apt-get install python-dev
sudo python setup.py install

I fixed this problem with the following steps:

sudo apt-get install libmysqlclient-dev
sudo apt-get install python-dev
sudo python setup.py install
鸩远一方 2024-12-12 12:12:06

命令(mysql 也是如此)mPATH 可能丢失。

导出PATH=$PATH:/usr/local/mysql/bin/

The commands (mysql too) mPATH might be missing.

export PATH=$PATH:/usr/local/mysql/bin/

⊕婉儿 2024-12-12 12:12:06

Step1:-安装Python3 & Python3-dev 两者

sudo apt-get install python3 python3-dev

第2步:- 安装Python和Python3-dev两者 Mysql 连接器

sudo apt-get install libmysqlclient-dev

步骤3:- 安装 python mysql 客户端

sudo apt-get install mysqlclient

这将解决您的问题

Step1:-Install Python3 & Python3-dev Both

sudo apt-get install python3 python3-dev

Step2:- Install Python & Mysql Connector

sudo apt-get install libmysqlclient-dev

step3:- Install python mysql client

sudo apt-get install mysqlclient

This will Solve your Problem

清风疏影 2024-12-12 12:12:06

libmysqlclient-dev 软件包已被弃用,因此请使用以下命令来修复它。

软件包 libmysqlclient-dev 不可用,但被另一个软件包引用。
这可能意味着该包丢失、已过时或
只能从其他来源获得

sudo apt-get install default-libmysqlclient-dev

The package libmysqlclient-dev is deprecated, so use the below command to fix it.

Package libmysqlclient-dev is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

sudo apt-get install default-libmysqlclient-dev
薄凉少年不暖心 2024-12-12 12:12:06

我认为 2020 年解决这个问题最方便的方法是使用另一个 python 包。我们不需要安装任何其他二进制软件。

试试这个

pip install mysql-connector-python

然后

import mysql.connector

mydb = mysql.connector.connect(
          host="",
          user="",
          passwd="",
          database=""
          )      
cursor = mydb.cursor( buffered=True)
cursor.execute('show tables;')
cursor.execute('insert into test values (null, "a",10)')
mydb.commit()
mydb.disconnect()

I think the most convenient way to solve this problem in 2020 is using another python package. We don't need install any other binary software.

Try this

pip install mysql-connector-python

and then

import mysql.connector

mydb = mysql.connector.connect(
          host="",
          user="",
          passwd="",
          database=""
          )      
cursor = mydb.cursor( buffered=True)
cursor.execute('show tables;')
cursor.execute('insert into test values (null, "a",10)')
mydb.commit()
mydb.disconnect()

十年不长 2024-12-12 12:12:06

如果您使用的是 macOS 并且已通过 brew install 安装了[email protected] :

  1. brew install mysql-connector-c
  2. brew unlink [电子邮件受保护]
  3. brew 链接 --overwrite --空运行 [email protected] 首先,查看哪些符号链接被覆盖
  4. brew link --overwrite --force [email protected] 实际上用 [电子邮件受保护]
  5. pip install mysqlclient

If you're on macOS and already installed [email protected] via brew install:

  1. brew install mysql-connector-c
  2. brew unlink [email protected]
  3. brew link --overwrite --dry-run [email protected] first, to see what symlinks are getting overwritten
  4. brew link --overwrite --force [email protected] to actually overwrite mysql-related symlinks with [email protected]
  5. pip install mysqlclient
小鸟爱天空丶 2024-12-12 12:12:06

我通过安装 libmysqlclient 修复了它:

sudo apt-get install libmysqlclient16-dev

I fixed it by installing libmysqlclient:

sudo apt-get install libmysqlclient16-dev
香草可樂 2024-12-12 12:12:06

在 centos 7 中,这对我有用:

yum install mariadb-devel
pip install mysqlclient

In centos 7 this works for me :

yum install mariadb-devel
pip install mysqlclient
长发绾君心 2024-12-12 12:12:06

MySQL-python 包使用 mysql_config 命令来了解主机上的 mysql 配置。您的主机没有 mysql_config 命令。

dev.mysql.com 的 MySQL 开发库包 (MySQL-devel-xxx) 提供了此命令以及 MySQL-python 包所需的库。 MySQL-devel 软件包可在下载 - 社区服务器区域中找到。 MySQL开发库包名称以MySQL-devel开头,并根据MySQL版本和Linux平台而有所不同(例如MySQL-devel-5.5.24-1.linux2.6.x86_64.rpm code>.)

请注意,您不需要安装 mysql 服务器。

The MySQL-python package is using the mysql_config command to learn about the mysql configuration on your host. Your host does not have the mysql_config command.

The MySQL development libraries package (MySQL-devel-xxx) from dev.mysql.com provides this command and the libraries needed by the MySQL-python package. The MySQL-devel packages are found in the download - community server area. The MySQL development library package names start with MySQL-devel and vary based MySQL version and linux platform (e.g. MySQL-devel-5.5.24-1.linux2.6.x86_64.rpm.)

Note that you do not need to install mysql server.

坠似风落 2024-12-12 12:12:06

对于 Alpine Linux:

$ apk add mariadb-dev mariadb-client mariadb-libs

MariaDB 是一个 MySQL 的直接替代品 并成为 Alpine 3.2 的新标准。请参阅https://bugs.alpinelinux.org/issues/4264

For Alpine Linux:

$ apk add mariadb-dev mariadb-client mariadb-libs

MariaDB is a drop-in replacement for MySQL and became the new standard as of Alpine 3.2. See https://bugs.alpinelinux.org/issues/4264

以歌曲疗慰 2024-12-12 12:12:06

在我的 Fedora 23 机器上,我必须运行以下命令:

sudo dnf install mysql-devel

On my Fedora 23 machine I had to run the following:

sudo dnf install mysql-devel
瞳孔里扚悲伤 2024-12-12 12:12:06

在 CentOS 7 中,应该执行以下操作:

#step1:install mysql 
https://dev.mysql.com/doc/mysql-yum-repo-quick-guide/en/

#step2:
sudo yum install mysql-devel

sudo yum install mysql-community-devel

In CentOS 7 , the following things should be done:

#step1:install mysql 
https://dev.mysql.com/doc/mysql-yum-repo-quick-guide/en/

#step2:
sudo yum install mysql-devel

or

sudo yum install mysql-community-devel
听闻余生 2024-12-12 12:12:06

另外,我也遇到了同样的问题
输入图片此处描述
我通过以下步骤解决了这个问题:
首先我运行这个命令

sudo apt-get install libmysqlclient-dev

,然后安装

pip install mysqlclient==2.1.0

这对我有用

also, i fetch the same problem
enter image description here
I fixed this problem with the following steps:
First I run this command

sudo apt-get install libmysqlclient-dev

then I install

pip install mysqlclient==2.1.0

this is worked for me

迷迭香的记忆 2024-12-12 12:12:06

我认为,可以在终端上执行以下几行

 sudo ln -s /usr/local/zend/mysql/bin/mysql_config /usr/sbin/

。此 mysql_config 目录适用于 MacOSx 上的 zend 服务器。你可以像下面的代码那样为 Linux 执行此操作

sudo ln -s /usr/local/mysql/bin/mysql_config /usr/sbin/

This is default linux mysql directory。

I think, following lines can be executed on terminal

 sudo ln -s /usr/local/zend/mysql/bin/mysql_config /usr/sbin/

This mysql_config directory is for zend server on MacOSx. You can do it for linux like following lines

sudo ln -s /usr/local/mysql/bin/mysql_config /usr/sbin/

This is default linux mysql directory.

浅忆 2024-12-12 12:12:06

我遇到了这个问题,并通过向 mysql_config 添加符号链接来解决。

我已经用 homebrew 安装了 mysql,并在输出中看到了这一点。

Error: The `brew link` step did not complete successfully

根据您获取 mysql 的方式,它将位于不同的位置。就我而言 /usr/local/Cellar/mysql
一旦你知道它在哪里,你应该能够建立一个符号链接到Python正在寻找它的地方。 /usr/local/mysql

这对我有用。

ln -s /usr/local/Cellar/mysql/<< VERSION >>/bin/mysql_config   /usr/local/mysql/bin/mysql_config

I had this issues and solved if by adding a symlink to mysql_config.

I had installed mysql with homebrew and saw this in the output.

Error: The `brew link` step did not complete successfully

Depending on how you got mysql it will be in different places. In my case /usr/local/Cellar/mysql
Once you know where it is you should be able to ma a symbolic link to where python is looking for it. /usr/local/mysql

This worked for me.

ln -s /usr/local/Cellar/mysql/<< VERSION >>/bin/mysql_config   /usr/local/mysql/bin/mysql_config
作死小能手 2024-12-12 12:12:06

我也有同样的问题。我按照 本教程在 Ubuntu 16.04 上使用 python3-dev 安装 Python:

sudo apt-get update
sudo apt-get -y upgrade
sudo apt-get install -y python3-pip
sudo apt-get install build-essential libssl-dev libffi-dev python3-dev

现在您可以设置虚拟环境:

sudo apt-get install -y python3-venv
pyvenv my_env
source my_env/bin/activate

I had the same problem. I solved it by following this tutorial to install Python with python3-dev on Ubuntu 16.04:

sudo apt-get update
sudo apt-get -y upgrade
sudo apt-get install -y python3-pip
sudo apt-get install build-essential libssl-dev libffi-dev python3-dev

And now you can set up your virtual environment:

sudo apt-get install -y python3-venv
pyvenv my_env
source my_env/bin/activate
自我难过 2024-12-12 12:12:06

您需要安装 python-dev 包:

sudo apt-get install python-dev

You need to install the python-dev package:

sudo apt-get install python-dev
碍人泪离人颜 2024-12-12 12:12:06

sudo apt-get install python-mysqldb

Python 2.5?听起来您使用的是非常旧版本的 Ubuntu Server(Hardy 8.04?) - 请确认服务器使用哪个 Linux 版本。

ubuntu 软件包数据库上的 python-mysql 搜索< /a>

一些附加信息:

的自述文件

来自 mysql-python - Red Hat Linux
......

MySQL-python 已预打包在 Red Hat Linux 7.x 及更高版本中。这
包括 Fedora Core 和 Red Hat Enterprise Linux。您还可以
如上所述构建您自己的 RPM 包。

Debian GNU/Linux
................

打包为 python-mysqldb_::

# apt-get install python-mysqldb

或者使用 Synaptic。

.. _python-mysqldb: http://packages.debian.org/python -mysqldb

Ubuntu
......

与 Debian 相同。

脚注:如果您确实使用早于 Ubuntu 10.04 的服务器发行版,那么您将不再获得官方支持,并且应该尽早升级。

sudo apt-get install python-mysqldb

Python 2.5? Sounds like you are using a very old version of Ubuntu Server (Hardy 8.04?) - please confirm which Linux version the server uses.

python-mysql search on ubuntu package database

Some additional info:

From the README of mysql-python -

Red Hat Linux
.............

MySQL-python is pre-packaged in Red Hat Linux 7.x and newer. This
includes Fedora Core and Red Hat Enterprise Linux. You can also
build your own RPM packages as described above.

Debian GNU/Linux
................

Packaged as python-mysqldb_::

# apt-get install python-mysqldb

Or use Synaptic.

.. _python-mysqldb: http://packages.debian.org/python-mysqldb

Ubuntu
......

Same as with Debian.

Footnote: If you really are using a server distribution older than Ubuntu 10.04 then you are out of official support, and should upgrade sooner rather than later.

人│生佛魔见 2024-12-12 12:12:06

此方法仅适用于那些知道Mysql已安装但仍找不到mysql_config的人。如果 python install 在系统路径中找不到 mysql_config,就会发生这种情况,如果您通过 .dmg Mac Package 完成安装或安装在某个自定义路径,则通常会发生这种情况。 MySqlDB 最简单且有记录的方法是更改​​ site.cfg。找到可能位于 /usr/local/mysql/bin/ 中的 mysql_config 并更改变量 mysql_config ,如下所示,然后再次运行安装。不要忘记通过删除“#”来取消注释,

更改以下行

“#mysql_config = /usr/local/bin/mysql_config”

“mysql_config = /usr/local/mysql/bin/mysql_config”

取决于系统中的路径。

顺便说一句,我在更改 site.cfg

sudo /System/Library/Frameworks/Python.framework/Versions/2.7/bin/python setup.py install后使用了 python install

This method is only for those who know that Mysql is installed but still mysql_config can't be find. This happens if python install can't find mysql_config in your system path, which mostly happens if you have done the installation via .dmg Mac Package or installed at some custom path. The easiest and documented way by MySqlDB is to change the site.cfg. Find the mysql_config which is probably in /usr/local/mysql/bin/ and change the variable namely mysql_config just like below and run the installation again. Don't forget to un-comment it by removing "#"

Change below line

"#mysql_config = /usr/local/bin/mysql_config"

to

"mysql_config = /usr/local/mysql/bin/mysql_config"

depending upon the path in your system.

By the way I used python install after changing the site.cfg

sudo /System/Library/Frameworks/Python.framework/Versions/2.7/bin/python setup.py install

世界等同你 2024-12-12 12:12:06

只需输入:

$ sudo apt-get install python-dev
$ venv/bin/pip install MySQL-python

这将解决这个问题。

Just type:

$ sudo apt-get install python-dev
$ venv/bin/pip install MySQL-python

This will solve this problems.

风苍溪 2024-12-12 12:12:06

到目前为止,所有解决方案 (Linux) 都需要 sudo 或 root 权限才能安装。
如果您没有root权限并且没有sudo,这里有一个解决方案。 (没有sudo apt install ...):

  1. 下载libmysqlclient-dev的.deb文件,例如从此镜像
  2. 导航到下载的文件并运行 dpkg -x libmysqlclient-dev_.deb . 这将提取一个名为 usr 的文件夹。
  3. ./usr/bin/mysql_config 符号链接到 $PATH 上的某个位置:

    ln -s `pwd` /usr/bin/mysql_config FOLDER_IN_YOUR_PATH

  4. 现在应该能够找到 mysql_config

在 Ubuntu 18.04 上测试。

So far, all solutions (Linux) require sudo or root rights to install .
Here is a solution if you do not have root rights and without sudo. (no sudo apt install ...):

  1. Download the .deb file of the libmysqlclient-dev, e.g. from this mirror
  2. Navigate to the downloaded file and run dpkg -x libmysqlclient-dev_<version tag>.deb . This will extract a folder called usr.
  3. Symlink ./usr/bin/mysql_config to somewhere that is found on your $PATH:

    ln -s `pwd` /usr/bin/mysql_config FOLDER_IN_YOUR_PATH

  4. It should now be able to find mysql_config

Tested on Ubuntu 18.04.

攒一口袋星星 2024-12-12 12:12:06

对于 macOS Mojave ,需要额外的配置,为了让编译器找到 openssl ,您可能需要设置:

export LDFLAGS="-L/usr/local/opt/openssl/lib"
export CPPFLAGS="-I/usr/local/opt/openssl/include"

For macOS Mojave , additional configuration was required, for compilers to find openssl you may need to set:

export LDFLAGS="-L/usr/local/opt/openssl/lib"
export CPPFLAGS="-I/usr/local/opt/openssl/include"
黄昏下泛黄的笔记 2024-12-12 12:12:06

在 MacOS (OS/X) Catalina 上,我发现我需要执行以下操作:

 export PATH=$PATH:/usr/local/bin/:/usr/local/mysql-5.7.16-osx10.11-x86_64/bin/

在我的计算机上,mysql 命令位于 /usr/local/bin (来自标准 MacOS 安装程序,而不是“brew”)。

On MacOS (OS/X) Catalina, I found that I needed to do this:

 export PATH=$PATH:/usr/local/bin/:/usr/local/mysql-5.7.16-osx10.11-x86_64/bin/

On my computer, the mysql command is in /usr/local/bin (from the standard MacOS installer, not "brew").

¢蛋碎的人ぎ生 2024-12-12 12:12:05

mySQLdb 是 mysql 的 python 接口,但它不是 mysql 本身。显然 mySQLdb 需要命令“mysql_config”,因此您需要先安装它。

您能否通过从 shell 运行“mysql”来确认您是否安装了 mysql 本身?这应该给你一个除了“mysql:命令未找到”之外的响应。

您使用的是哪个 Linux 发行版? Mysql 已针对大多数 Linux 发行版进行了预打包。例如,对于 debian / ubuntu,安装 mysql 很简单,因为

sudo apt-get install mysql-server

mysql-config 位于不同的包中,可以从以下位置安装(再次假设 debian / ubuntu):

sudo apt-get install libmysqlclient-dev

如果您使用 mariadb,则可以替换 mysql,然后运行

sudo apt-get install libmariadbclient-dev

参考:
https://github.com/JudgeGirl/Judge-sender/issues/4 #issuecomment-186542797

mySQLdb is a python interface for mysql, but it is not mysql itself. And apparently mySQLdb needs the command 'mysql_config', so you need to install that first.

Can you confirm that you did or did not install mysql itself, by running "mysql" from the shell? That should give you a response other than "mysql: command not found".

Which linux distribution are you using? Mysql is pre-packaged for most linux distributions. For example, for debian / ubuntu, installing mysql is as easy as

sudo apt-get install mysql-server

mysql-config is in a different package, which can be installed from (again, assuming debian / ubuntu):

sudo apt-get install libmysqlclient-dev

if you are using mariadb, the drop in replacement for mysql, then run

sudo apt-get install libmariadbclient-dev

Reference:
https://github.com/JudgeGirl/Judge-sender/issues/4#issuecomment-186542797

老娘不死你永远是小三 2024-12-12 12:12:05

我在 Ubuntu 12.04 上安装 python-mysql

pip install mysql-python

首先我遇到了同样的问题:

Not Found "mysql_config"

这对我有用

$ sudo apt-get install libmysqlclient-dev

然后我遇到了这个问题:

...
_mysql.c:29:20: error fatal: Python.h: No existe el archivo o el directorio

compilación terminada.

error: command 'gcc' failed with exit status 1

然后我尝试使用

apt-get install python-dev

(如果您使用的是 python3,请安装 python3-dev 代替。)

然后我很高兴:)

pip install mysql-python
    Installing collected packages: mysql-python
      Running setup.py install for mysql-python
        building '_mysql' extension
        gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -Dversion_info=(1,2,4,'beta',4) -D__version__=1.2.4b4 -I/usr/include/mysql -I/usr/include/python2.7 -c _mysql.c -o build/temp.linux-x86_64-2.7/_mysql.o -DBIG_JOINS=1 -fno-strict-aliasing -g
        In file included from _mysql.c:44:0:
        /usr/include/mysql/my_config.h:422:0: aviso: se redefinió "HAVE_WCSCOLL" [activado por defecto]
        /usr/include/python2.7/pyconfig.h:890:0: nota: esta es la ubicación de la definición previa
        gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -Wl,-z,relro build/temp.linux-x86_64-2.7/_mysql.o -L/usr/lib/x86_64-linux-gnu -lmysqlclient_r -lpthread -lz -lm -lrt -ldl -o build/lib.linux-x86_64-2.7/_mysql.so
    
Successfully installed mysql-python
Cleaning up...

I was installing python-mysql on Ubuntu 12.04 using

pip install mysql-python

First I had the same problem:

Not Found "mysql_config"

This worked for me

$ sudo apt-get install libmysqlclient-dev

Then I had this problem:

...
_mysql.c:29:20: error fatal: Python.h: No existe el archivo o el directorio

compilación terminada.

error: command 'gcc' failed with exit status 1

Then I tried with

apt-get install python-dev

(If you're using python3, install python3-dev instead.)

And then I was happy :)

pip install mysql-python
    Installing collected packages: mysql-python
      Running setup.py install for mysql-python
        building '_mysql' extension
        gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -Dversion_info=(1,2,4,'beta',4) -D__version__=1.2.4b4 -I/usr/include/mysql -I/usr/include/python2.7 -c _mysql.c -o build/temp.linux-x86_64-2.7/_mysql.o -DBIG_JOINS=1 -fno-strict-aliasing -g
        In file included from _mysql.c:44:0:
        /usr/include/mysql/my_config.h:422:0: aviso: se redefinió "HAVE_WCSCOLL" [activado por defecto]
        /usr/include/python2.7/pyconfig.h:890:0: nota: esta es la ubicación de la definición previa
        gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -Wl,-z,relro build/temp.linux-x86_64-2.7/_mysql.o -L/usr/lib/x86_64-linux-gnu -lmysqlclient_r -lpthread -lz -lm -lrt -ldl -o build/lib.linux-x86_64-2.7/_mysql.so
    
Successfully installed mysql-python
Cleaning up...
唱一曲作罢 2024-12-12 12:12:05

(特定于Mac OS X)

我尝试了很多东西,但是这组命令最终对我有用。

  1. 安装mysql
    brew 安装 mysql
    
  2. brew unlink mysql
  3. brew install mysql-connector-c
  4. 将 mysql bin 文件夹添加到 PATH
    导出 PATH=/usr/local/Cellar/mysql/8.0.11/bin:$PATH
    
  5. mkdir /usr/local/Cellar/lib/
  6. 创建符号链接
    sudo ln -s /usr/local/Cellar/mysql/8.0.11/lib/libmysqlclient.21.dylib /usr/local/Cellar/lib/libmysqlclient.21.dylib
    
  7. brew 重新安装 openssl (来源
  8. 最后,安装mysql-client
    LIBRARY_PATH=$LIBRARY_PATH:/usr/local/opt/openssl/lib/ pip install mysqlclient
    更新


如果这不起作用,@vinyll 建议在步骤 8 之前运行 brew link mysql

(Specific to Mac OS X)

I have tried a lot of things, but these set of commands finally worked for me.

  1. Install mysql
    brew install mysql
    
  2. brew unlink mysql
  3. brew install mysql-connector-c
  4. Add the mysql bin folder to PATH
    export PATH=/usr/local/Cellar/mysql/8.0.11/bin:$PATH
    
  5. mkdir /usr/local/Cellar/lib/
  6. Create a symlink
    sudo ln -s /usr/local/Cellar/mysql/8.0.11/lib/libmysqlclient.21.dylib /usr/local/Cellar/lib/libmysqlclient.21.dylib
    
  7. brew reinstall openssl (source)
  8. Finally, install mysql-client
    LIBRARY_PATH=$LIBRARY_PATH:/usr/local/opt/openssl/lib/ pip install mysqlclient
    

Update:
In case this doesn't work, @vinyll suggests to run brew link mysql before step 8.

森林很绿却致人迷途 2024-12-12 12:12:05

在红帽上我必须这样做

sudo yum install mysql-devel gcc gcc-devel python-devel
sudo easy_install mysql-python

然后它就起作用了。

On Red Hat I had to do

sudo yum install mysql-devel gcc gcc-devel python-devel
sudo easy_install mysql-python

Then it worked.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文