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ẻ 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ẻ 0 bình luận chia sẻ
answer
21
Tôi cần những thứ sau để xây dựng / cài đặt mysqlclient
1.brew install mysql-connector-c
brew install mysql-connector-c
2.pip install mysqlclient
pip install mysqlclient
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ẻ
1.
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/"
12.pip install mysqlclient
Tôi cũng gặp phải vấn đề này , dưới đây là bước của tôi :
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. 1 bình luận chia sẻ
answer
12
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/"
6brew 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/"
7brew 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/"
8pip install mysqlclient
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ẻ
Tôi cũng gặp phải vấn đề này , dưới đây là bước của tôi : 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
Tôi cần những thứ sau để xây dựng / cài đặt mysqlclient
3 bình luận chia sẻ
answer
7
Tôi cần những thứ sau để xây dựng / cài đặt mysqlclient
Sau đó, tôi có thể pip wheel mysqlclient
/ pip install mysqlclient
thành công
$ brew install mysql
$ export PATH=$PATH:/Applications/MySQLWorkbench.app/Contents/MacOS
$ xcode-select --install
$ pip install mysqlclient
48 hữu ích 0 bình luận chia sẻ 2 bình luận chia sẻ
answer
3
Tôi cần những thứ sau để xây dựng / cài đặt mysqlclient
$ 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
Sau đó, tôi có thể pip wheel mysqlclient
/ pip install mysqlclient
thành công 0 bình luận chia sẻ