Those instructions are for Debian type Linuxes. The closest thing to Debian for OS X is Fink. After getting that installed and set up, you can say fink install mysql-unified-dev
to get essentially the same thing as asking for libmysqlclient15-dev
on a Debian or Ubuntu type system.
Beware that Fink installs its packages in /sw
, and not all build scripts know to look there for libraries and headers. You might have to
give custom build options to get it to figure this out.
A path that may be more successful is to simply download the MySQL 5.0 package for Mac OS X. That should include the same development files as libmysqlclient15-dev
, and as a bonus will put them in places more likely to be found by your gem.
[Why 5.0, by the way? Because that's what corresponds to ABI version 15, which your package apparently requires. Maybe it will in fact work with 5.1, or 5.4, or 6.0, but that would be a risk you'd have to decide to take on your own.]
Tôi đã cài đặt rồi
- Python 2.7.13
- Django 1.11
- MySQL 5.7.17
Tôi muốn sử dụng MySQL với Django, nhưng sau khi cài đặt trình kết nối mysql, tôi đã cố gắng cài đặt mysqlclient cho Python $ pip install mysqlclient
, nhưng tôi gặp sự cố này:
Collecting mysqlclient
Using cached mysqlclient-1.3.10.tar.gz
Complete output from command python setup.py egg_info:
Traceback [most recent call last]:
File "", line 1, in
File "/private/var/folders/y_/c31n_1v12v169zfv829p_v_80000gn/T/pip-build-f51KhW/mysqlclient/setup.py", line 17, in
metadata, options = get_config[]
File "setup_posix.py", line 54, in get_config
libraries = [dequote[i[2:]] for i in libs if i.startswith['-l']]
File "setup_posix.py", line 12, 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/var/folders/y_/c31n_1v12v169zfv829p_v_80000gn/T/pip-build-f51KhW/mysqlclient/
- python
- mysql
- django
- macos
21 hữu ích 1 bình luận 33k xem chia sẻ
answer
48
Tôi cần những thứ sau để xây dựng / cài đặt mysqlclient
brew install mysql-client
# mysql-client is not on the `PATH` by default
export PATH="/usr/local/opt/mysql-client/bin:$PATH"
# openssl is not on the link path by default
export LIBRARY_PATH="$LIBRARY_PATH:/usr/local/opt/openssl/lib/"
Sau đó, tôi có thể pip wheel mysqlclient
/ pip install mysqlclient
thành công
48 hữu ích 0 bình luận chia sẻ
answer
21
Tôi cũng gặp phải vấn đề này , dưới đây là bước của tôi :
1.brew install mysql-connector-c
2.pip install mysqlclient
và sau đó gặp lỗi này, tôi đã Truy xuất mã nguồn , nhưng giải quyết được lỗi này thì lỗi khác lại xảy ra.
vì vậy tôi đã thay đổi cách cài đặt mysqlclient, chỉ cần:
1.brew install mysql
2.pip install mysqlclient
điều này đã làm việc cho tôi, không có bất kỳ lỗi nào xảy ra.
21 hữu ích 1 bình luận chia sẻ
answer
12
Cài đặt mysql-client
thay vì cài đặt mysql
nếu bạn không định có mysql
trong máy tính
của mình
brew install mysql-client
echo 'export PATH="/usr/local/opt/mysql-client/bin:$PATH"' >> ~/.bash_profile
source ~/.bash_profile
pip install mysqlclient
xuất LDFLAGS = "- L / usr / local / opt / openssl / lib"
xuất CPPFLAGS = "- I / usr / local / opt / openssl / include"
12 hữu ích 2 bình luận chia sẻ
answer
11
brew install/upgrade/reinstall mysql
brew install mysql-client
export PATH="/usr/local/opt/openssl/bin:$PATH"
export LDFLAGS="-L/usr/local/opt/openssl/lib"
export CPPFLAGS="-I/usr/local/opt/openssl/include"
pip install mysqlclient
works perfectly
11 hữu ích 3 bình luận chia sẻ
answer
7
Đối với Mac: trước tiên hãy tải xuống Xcode từ App Store và MySqlWorkbench từ //dev.mysql.com/downloads/workbench/
Chạy các lệnh sau trong thiết bị đầu cuối,
$ brew install mysql
$ export PATH=$PATH:/Applications/MySQLWorkbench.app/Contents/MacOS
$ xcode-select --install
$ pip install mysqlclient
7 hữu ích 2 bình luận chia sẻ
answer
3
Cài đặt mysql bằng cách sử dụng brew và thêm nó vào đường dẫn:
$ brew install mysql
$ export PATH=/usr/local/mysql/bin:$PATH
$ sudo ln -s /usr/local/mysql/lib/libmysqlclient.18.dylib /usr/local/lib/libmysqlclient.18.dylib
$ pip install mysqlclient
3 hữu ích 0 bình luận chia sẻ