- 安装flask-mysqldb失败
zhongweideMacBook-Pro:~ ShawnZhong$ sudo pip install flask-mysqldb
Password:
The directory '/Users/ShawnZhong/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/ShawnZhong/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 flask-mysqldb
Downloading Flask-MySQLdb-0.2.0.tar.gz
Requirement already satisfied (use --upgrade to upgrade): Flask>=0.10 in /Library/Python/2.7/site-packages (from flask-mysqldb)
Collecting mysqlclient (from flask-mysqldb)
Downloading mysqlclient-1.3.7.tar.gz (79kB)
100% |████████████████████████████████| 81kB 69kB/s
Complete output from command python setup.py egg_info:
sh: mysql_config: command not found
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/private/tmp/pip-build-L6g39J/mysqlclient/setup.py", line 17, in <module>
metadata, options = get_config()
File "setup_posix.py", line 44, in get_config
libs = mysql_config("libs_r")
File "setup_posix.py", line 26, in mysql_config
raise EnvironmentError("%s not found" % (mysql_config.path,))
EnvironmentError: mysql_config not found
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /private/tmp/pip-build-L6g39J/mysqlclient/
You are using pip version 8.1.0, however version 8.1.2 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
zhongweideMacBook-Pro:~ ShawnZhong$ locate mysql_config
/usr/local/mysql-5.7.11-osx10.9-x86_64/bin/mysql_config
/usr/local/mysql-5.7.11-osx10.9-x86_64/bin/mysql_config_editor
/usr/local/mysql-5.7.11-osx10.9-x86_64/man/man1/mysql_config.1
/usr/local/mysql-5.7.11-osx10.9-x86_64/man/man1/mysql_config_editor.1
zhongweideMacBook-Pro:~ ShawnZhong$ export PATH=$PATH:/usr/local/mysql-5.7.11-osx10.9-x86_64/bin
zhongweideMacBook-Pro:~ ShawnZhong$ echo $?
0
zhongweideMacBook-Pro:~ ShawnZhong$ sudo pip install flask-mysqldb
The directory '/Users/ShawnZhong/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/ShawnZhong/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 flask-mysqldb
Downloading Flask-MySQLdb-0.2.0.tar.gz
Requirement already satisfied (use --upgrade to upgrade): Flask>=0.10 in /Library/Python/2.7/site-packages (from flask-mysqldb)
Collecting mysqlclient (from flask-mysqldb)
Downloading mysqlclient-1.3.7.tar.gz (79kB)
100% |████████████████████████████████| 81kB 196kB/s
Requirement already satisfied (use --upgrade to upgrade): click>=2.0 in /Library/Python/2.7/site-packages (from Flask>=0.10->flask-mysqldb)
Requirement already satisfied (use --upgrade to upgrade): itsdangerous>=0.21 in /Library/Python/2.7/site-packages (from Flask>=0.10->flask-mysqldb)
Requirement already satisfied (use --upgrade to upgrade): Werkzeug>=0.7 in /Library/Python/2.7/site-packages (from Flask>=0.10->flask-mysqldb)
Requirement already satisfied (use --upgrade to upgrade): Jinja2>=2.4 in /Library/Python/2.7/site-packages (from Flask>=0.10->flask-mysqldb)
Requirement already satisfied (use --upgrade to upgrade): MarkupSafe in /Library/Python/2.7/site-packages (from Jinja2>=2.4->Flask>=0.10->flask-mysqldb)
Installing collected packages: mysqlclient, flask-mysqldb
Running setup.py install for mysqlclient ... done
Running setup.py install for flask-mysqldb ... done
Successfully installed flask-mysqldb-0.2.0 mysqlclient-1.3.7
You are using pip version 8.1.0, however version 8.1.2 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
解决方法:export PATH=$PATH:/usr/local/mysql-5.7.11-osx10.9-x86_64/bin