问题描述,pip install mysqlclient 时候报mysql_config不存在
(venv) userdeMacBook-Pro:OnlineSchemaChange root# pip install mysqlclient
WARNING: The directory '/Users/user/Library/Caches/pip' or its parent directory is not owned or is not writable by the current user. The cache has been disabled. Check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Collecting mysqlclient
Downloading mysqlclient-2.0.1.tar.gz (87 kB)
|████████████████████████████████| 87 kB 112 kB/s
ERROR: Command errored out with exit status 1:
command: /Users/user/PycharmProjects/OnlineSchemaChange/venv/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/tmp/pip-install-tygih1l5/mysqlclient/setup.py'"'"'; __file__='"'"'/private/tmp/pip-install-tygih1l5/mysqlclient/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /private/tmp/pip-pip-egg-info-p9l3wmc0
cwd: /private/tmp/pip-install-tygih1l5/mysqlclient/
Complete output (12 lines):
/bin/sh: mysql_config: command not found
/bin/sh: mariadb_config: command not found
/bin/sh: mysql_config: command not found
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/private/tmp/pip-install-tygih1l5/mysqlclient/setup.py", line 15, in <module>
metadata, options = get_config()
File "/private/tmp/pip-install-tygih1l5/mysqlclient/setup_posix.py", line 65, in get_config
libs = mysql_config("libs")
File "/private/tmp/pip-install-tygih1l5/mysqlclient/setup_posix.py", line 31, in mysql_config
raise OSError("{} not found".format(_mysql_config_path))
OSError: mysql_config not found
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
解决方法
查了资料 配合自己的环境
我的mac中没有装mysqlclient 遇到man8没有授权,授权后安装成功
userdeMacBook-Pro:~ user$ brew install mysql-client
Error: The following directories are not writable by your user:
/usr/local/share/man/man8
You should change the ownership of these directories to your user.
sudo chown -R $(whoami) /usr/local/share/man/man8
And make sure that your user has write permission.
chmod u+w /usr/local/share/man/man8
userdeMacBook-Pro:~ user$ sudo chown -R $(whoami) /usr/local/share/man/man8
Password:
userdeMacBook-Pro:~ user$ brew install mysql-client
==> Downloading https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles/bottles/mysql-clien
######################################################################## 100.0%
==> Pouring mysql-client-8.0.18.catalina.bottle.tar.gz
==> Caveats
mysql-client is keg-only, which means it was not symlinked into /usr/local,
because it conflicts with mysql (which contains client libraries).
If you need to have mysql-client first in your PATH run:
echo 'export PATH="/usr/local/opt/mysql-client/bin:$PATH"' >> ~/.bash_profile
For compilers to find mysql-client you may need to set:
export LDFLAGS="-L/usr/local/opt/mysql-client/lib"
export CPPFLAGS="-I/usr/local/opt/mysql-client/include"
==> Summary
🍺 /usr/local/Cellar/mysql-client/8.0.18: 127 files, 137.6MB
==> `brew cleanup` has not been run in 30 days, running now...
Removing: /Users/user/Library/Logs/Homebrew/wget... (64B)
Removing: /Users/user/Library/Logs/Homebrew/libidn2... (64B)
Removing: /Users/user/Library/Logs/Homebrew/ncurses... (64B)
Removing: /Users/user/Library/Logs/Homebrew/libunistring... (64B)
Removing: /Users/user/Library/Logs/Homebrew/perl... (64B)
Removing: /Users/user/Library/Logs/Homebrew/lz4... (64B)
Removing: /Users/user/Library/Logs/Homebrew/gettext... (64B)
Removing: /Users/user/Library/Logs/Homebrew/pcre2... (64B)
Removing: /Users/user/Library/Logs/Homebrew/rename... (64B)
Removing: /Users/user/Library/Logs/Homebrew/openssl@1.1... (64B)
Removing: /Users/user/Library/Logs/Homebrew/pcre... (64B)
Removing: /Users/user/Library/Logs/Homebrew/zsh... (64B)
Removing: /Users/user/Library/Logs/Homebrew/git... (64B)
Removing: /Users/user/Library/Logs/Homebrew/telnet... (64B)
Removing: /Users/user/Library/Logs/Homebrew/lrzsz... (64B)
Pruned 0 symbolic links and 5 directories from /usr/local
打印出MySQLclient的安装路径 设置环境变量
userdeMacBook-Pro:~ user$ brew list mysql-client
/usr/local/Cellar/mysql-client/8.0.18/bin/lz4_decompress
/usr/local/Cellar/mysql-client/8.0.18/bin/my_print_defaults
/usr/local/Cellar/mysql-client/8.0.18/bin/mysql
/usr/local/Cellar/mysql-client/8.0.18/bin/mysql_config
/usr/local/Cellar/mysql-client/8.0.18/bin/mysql_config_editor
/usr/local/Cellar/mysql-client/8.0.18/bin/mysql_secure_installation
/usr/local/Cellar/mysql-client/8.0.18/bin/mysql_ssl_rsa_setup
/usr/local/Cellar/mysql-client/8.0.18/bin/mysqladmin
/usr/local/Cellar/mysql-client/8.0.18/bin/mysqlbinlog
/usr/local/Cellar/mysql-client/8.0.18/bin/mysqlcheck
/usr/local/Cellar/mysql-client/8.0.18/bin/mysqldump
/usr/local/Cellar/mysql-client/8.0.18/bin/mysqlimport
/usr/local/Cellar/mysql-client/8.0.18/bin/mysqlpump
/usr/local/Cellar/mysql-client/8.0.18/bin/mysqlshow
/usr/local/Cellar/mysql-client/8.0.18/bin/mysqlslap
/usr/local/Cellar/mysql-client/8.0.18/bin/mysqltest
/usr/local/Cellar/mysql-client/8.0.18/bin/perror
/usr/local/Cellar/mysql-client/8.0.18/bin/zlib_decompress
/usr/local/Cellar/mysql-client/8.0.18/include/mysql/ (13 files)
/usr/local/Cellar/mysql-client/8.0.18/lib/libmysqlclient.21.dylib
/usr/local/Cellar/mysql-client/8.0.18/lib/pkgconfig/mysqlclient.pc
/usr/local/Cellar/mysql-client/8.0.18/lib/plugin/authentication_ldap_sasl_client.so
/usr/local/Cellar/mysql-client/8.0.18/lib/ (2 other files)
/usr/local/Cellar/mysql-client/8.0.18/share/doc/ (3 files)
/usr/local/Cellar/mysql-client/8.0.18/share/man/ (32 files)
/usr/local/Cellar/mysql-client/8.0.18/share/mysql/ (52 files)
在idea的终端中 设置环境变量
export PATH=$PATH:/usr/local/Cellar/mysql-client/8.0.18/bin/
开始安装 pip install mysqlclient 并且安装成功
(venv) userdeMacBook-Pro:OnlineSchemaChange root# pip install mysqlclient
WARNING: The directory '/Users/user/Library/Caches/pip' or its parent directory is not owned or is not writable by the current user. The cache has been disabled. Check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Collecting mysqlclient
Downloading mysqlclient-2.0.1.tar.gz (87 kB)
|████████████████████████████████| 87 kB 126 kB/s
Using legacy 'setup.py install' for mysqlclient, since package 'wheel' is not installed.
Installing collected packages: mysqlclient
Running setup.py install for mysqlclient ... done
Successfully installed mysqlclient-2.0.1