Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pip3 install mysqlclient fails on macOS #169

Closed
janikarh opened this issue May 3, 2017 · 26 comments

Comments

Projects
None yet
7 participants
@janikarh
Copy link

commented May 3, 2017

I am unable to install mysqlclient on macOS anymore via pip.

I'm on latest macOS, Python 3.6.1 and pip 9.0.1, within virtualenv.

The installation ends with:

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 "<string>", line 1, in <module>
      File "/private/var/folders/rv/a_a/T/pip-build-nyaa8t95/mysqlclient/setup.py", line 17, in <module>
        metadata, options = get_config()
      File "/private/var/folders/rv/a_a/T/pip-build-nyaa8t95/mysqlclient/setup_posix.py", line 54, in get_config
        libraries = [dequote(i[2:]) for i in libs if i.startswith('-l')]
      File "/private/var/folders/rv/a_a/T/pip-build-nyaa8t95/mysqlclient/setup_posix.py", line 54, in <listcomp>
        libraries = [dequote(i[2:]) for i in libs if i.startswith('-l')]
      File "/private/var/folders/rv/a_a/T/pip-build-nyaa8t95/mysqlclient/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/rv/a_a/T/pip-build-nyaa8t95/mysqlclient/

Result is the same with locally installed MySQL, or with the light-weight option brew install mysql-connector-c.

Similar issues have been posted to Stack Overflow by several people. Any ideas appreciated.

@methane

This comment has been minimized.

Copy link
Member

commented May 4, 2017

Could you give me output of mysql_config?

@janikarh

This comment has been minimized.

Copy link
Author

commented May 4, 2017

I assume you want this:

mysql_config --libs_r

# output:
-L/usr/local/Cellar/mysql-connector-c/6.1.10/lib -l
@JooeunAhn

This comment has been minimized.

Copy link

commented May 4, 2017

I have the same problem. How can I pass that error?

@methane

This comment has been minimized.

Copy link
Member

commented May 4, 2017

@janikarh Yes, it's I want. FYI, mysql_config shows all information when no options are passed. That's what I said.

$ mysql_config 
Usage: /usr/bin/mysql_config [OPTIONS]
Compiler: GNU 6.3.0
Options:
        --cflags         [-I/usr/include/mysql ]
        --cxxflags       [-I/usr/include/mysql ]
        --include        [-I/usr/include/mysql]
        --libs           [-L/usr/lib/x86_64-linux-gnu -lmysqlclient -lpthread -lz -lm -lrt -latomic -ldl]
        --libs_r         [-L/usr/lib/x86_64-linux-gnu -lmysqlclient -lpthread -lz -lm -lrt -latomic -ldl]
        --plugindir      [/usr/lib/mysql/plugin]
        --socket         [/var/run/mysqld/mysqld.sock]
        --port           [0]
        --version        [5.7.18]
        --libmysqld-libs [-L/usr/lib/x86_64-linux-gnu -lmysqld -lpthread -lz -lm -lrt -latomic -lcrypt -ldl -laio -llz4 -lnuma]
        --variable=VAR   VAR is one of:
                pkgincludedir [/usr/include/mysql]
                pkglibdir     [/usr/lib/x86_64-linux-gnu]
                plugindir     [/usr/lib/mysql/plugin]

Anyway, your mysql_config seems broken. There should be -lmysqlclient at least.

@janikarh

This comment has been minimized.

Copy link
Author

commented May 4, 2017

Based on Stack Overflow, I'm not alone, and there is no fix available. Which is not good. Guess I'll migrate my DB backend to PostgreSQL to resolve my dev issue.

Do you want to keep this issue open, or should I close this? I'm cool either way.

@methane

This comment has been minimized.

Copy link
Member

commented May 4, 2017

@janikarh

This comment has been minimized.

Copy link
Author

commented May 4, 2017

There is something else going on here. I removed the Homebrew installed Connector/C, and installed directly from https://dev.mysql.com/downloads/connector/c/ binary. End result is the same:

mysql_config
Usage: /usr/local/mysql-connector-c-6.1.10-macos10.12-x86_64/bin/mysql_config [OPTIONS]
Options:
        --cflags         [-I/usr/local/mysql-connector-c-6.1.10-macos10.12-x86_64/include ]
        --cxxflags       [-I/usr/local/mysql-connector-c-6.1.10-macos10.12-x86_64/include ]
        --include        [-I/usr/local/mysql-connector-c-6.1.10-macos10.12-x86_64/include]
        --libs           [-L/usr/local/mysql-connector-c-6.1.10-macos10.12-x86_64/lib -l ]
        --libs_r         [-L/usr/local/mysql-connector-c-6.1.10-macos10.12-x86_64/lib -l ]
        --plugindir      [/usr/local/mysql/lib/plugin]
        --socket         [/tmp/mysql.sock]
        --port           [0]
        --version        [6.1.10]
        --variable=VAR   VAR is one of:
                pkgincludedir [/usr/local/mysql-connector-c-6.1.10-macos10.12-x86_64/include]
                pkglibdir     [/usr/local/mysql-connector-c-6.1.10-macos10.12-x86_64/lib]
                plugindir     [/usr/local/mysql/lib/plugin]

My guess is that MySQL (Oracle) has changed something, maybe.

Unfortunately I have no more time to dig into this issue, I'm migrating to PostgreSQL. Guess this issue will be opened again, if someone else wants to report it. Thanks for your help!

@janikarh janikarh closed this May 4, 2017

@rimonberhe

This comment has been minimized.

Copy link

commented May 5, 2017

I am having this exact same problem! What is the fix??

@methane

This comment has been minimized.

Copy link
Member

commented May 5, 2017

@methane

This comment has been minimized.

Copy link
Member

commented May 8, 2017

There is lines in mysql_config like following:

# Create options 
libs="-L$pkglibdir"
libs="$libs -l "

It should be:

# Create options 
libs="-L$pkglibdir"
libs="$libs -lmysqlclient -lssl -lcrypto"
@ning1022

This comment has been minimized.

Copy link

commented May 14, 2017

i do this

# Create options 
libs="-L$pkglibdir"
libs="$libs -lmysqlclient -lssl -lcrypto"

but a new problem has come up

    running build_ext
    building '_mysql' extension
    creating build/temp.macosx-10.6-intel-3.5
    /usr/bin/clang -fno-strict-aliasing -Wsign-compare -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -arch i386 -arch x86_64 -g -Dversion_info=(1,3,10,'final',0) -D__version__=1.3.10 -I/usr/local/Cellar/mysql-connector-c/6.1.10/include -I/Library/Frameworks/Python.framework/Versions/3.5/include/python3.5m -c _mysql.c -o build/temp.macosx-10.6-intel-3.5/_mysql.o
    /usr/bin/clang -bundle -undefined dynamic_lookup -arch i386 -arch x86_64 -g build/temp.macosx-10.6-intel-3.5/_mysql.o -L/usr/local/Cellar/mysql-connector-c/6.1.10/lib -lmysqlclient -lssl -lcrypto -o build/lib.macosx-10.6-intel-3.5/_mysql.cpython-35m-darwin.so
    ld: library not found for -lssl
    clang: error: linker command failed with exit code 1 (use -v to see invocation)
    error: command '/usr/bin/clang' failed with exit status 1

This detailed output

Collecting mysqlclient
  1 location(s) to search for versions of mysqlclient:
  * https://pypi.python.org/simple/mysqlclient/
  Getting page https://pypi.python.org/simple/mysqlclient/
...
  Downloading from URL https://pypi.python.org/packages/40/9b/0bc869f290b8f49a99b8d97927f57126a5d1befcf8bac92c60dc855f2523/mysqlclient-1.3.10.tar.gz#md5=e7fb95c4055e2d8a3322db5c85ab6fc8 (from https://pypi.python.org/simple/mysqlclient/)
  Running setup.py (path:/private/var/folders/1k/_yh_dpzn721401tdqztp_qb40000gn/T/pip-build-32q202m5/mysqlclient/setup.py) egg_info for package mysqlclient
    Running command python setup.py egg_info
    running egg_info
    creating pip-egg-info/mysqlclient.egg-info
    writing pip-egg-info/mysqlclient.egg-info/PKG-INFO
    writing top-level names to pip-egg-info/mysqlclient.egg-info/top_level.txt
    writing dependency_links to pip-egg-info/mysqlclient.egg-info/dependency_links.txt
    writing manifest file 'pip-egg-info/mysqlclient.egg-info/SOURCES.txt'
    reading manifest file 'pip-egg-info/mysqlclient.egg-info/SOURCES.txt'
    reading manifest template 'MANIFEST.in'
    warning: no files found matching 'GPL-2.0'
    writing manifest file 'pip-egg-info/mysqlclient.egg-info/SOURCES.txt'
  Source in /private/var/folders/1k/_yh_dpzn721401tdqztp_qb40000gn/T/pip-build-32q202m5/mysqlclient has version 1.3.10, which satisfies requirement mysqlclient from https://pypi.python.org/packages/40/9b/0bc869f290b8f49a99b8d97927f57126a5d1befcf8bac92c60dc855f2523/mysqlclient-1.3.10.tar.gz#md5=e7fb95c4055e2d8a3322db5c85ab6fc8
Building wheels for collected packages: mysqlclient
  Running setup.py bdist_wheel for mysqlclient: started
  Destination directory: /var/folders/1k/_yh_dpzn721401tdqztp_qb40000gn/T/tmp_xiqz2w4pip-wheel-
  Running command /Users/ning-pc/Envs/python3.5/bin/python3 -u -c "import setuptools, tokenize;__file__='/private/var/folders/1k/_yh_dpzn721401tdqztp_qb40000gn/T/pip-build-32q202m5/mysqlclient/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d /var/folders/1k/_yh_dpzn721401tdqztp_qb40000gn/T/tmp_xiqz2w4pip-wheel- --python-tag cp35
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build/lib.macosx-10.6-intel-3.5
...
  running build_ext
  building '_mysql' extension
  creating build/temp.macosx-10.6-intel-3.5
  /usr/bin/clang -fno-strict-aliasing -Wsign-compare -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -arch i386 -arch x86_64 -g -Dversion_info=(1,3,10,'final',0) -D__version__=1.3.10 -I/usr/local/Cellar/mysql-connector-c/6.1.10/include -I/Library/Frameworks/Python.framework/Versions/3.5/include/python3.5m -c _mysql.c -o build/temp.macosx-10.6-intel-3.5/_mysql.o
  /usr/bin/clang -bundle -undefined dynamic_lookup -arch i386 -arch x86_64 -g build/temp.macosx-10.6-intel-3.5/_mysql.o -L/usr/local/Cellar/mysql-connector-c/6.1.10/lib -lmysqlclient -lssl -lcrypto -o build/lib.macosx-10.6-intel-3.5/_mysql.cpython-35m-darwin.so
  ld: library not found for -lssl
  clang: error: linker command failed with exit code 1 (use -v to see invocation)
  error: command '/usr/bin/clang' failed with exit status 1
  Running setup.py bdist_wheel for mysqlclient: finished with status 'error'
  Running setup.py clean for mysqlclient
  Running command /Users/ning-pc/Envs/python3.5/bin/python3 -u -c "import setuptools, tokenize;__file__='/private/var/folders/1k/_yh_dpzn721401tdqztp_qb40000gn/T/pip-build-32q202m5/mysqlclient/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" clean --all
  running clean
  removing 'build/temp.macosx-10.6-intel-3.5' (and everything under it)
  removing 'build/lib.macosx-10.6-intel-3.5' (and everything under it)
  'build/bdist.macosx-10.6-intel' does not exist -- can't clean it
  'build/scripts-3.5' does not exist -- can't clean it
  removing 'build'
Failed to build mysqlclient
Installing collected packages: mysqlclient
  Running setup.py install for mysqlclient: started
    Running command /Users/ning-pc/Envs/python3.5/bin/python3 -u -c "import setuptools, tokenize;__file__='/private/var/folders/1k/_yh_dpzn721401tdqztp_qb40000gn/T/pip-build-32q202m5/mysqlclient/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /var/folders/1k/_yh_dpzn721401tdqztp_qb40000gn/T/pip-_rn86vr2-record/install-record.txt --single-version-externally-managed --compile --install-headers /Users/ning-pc/Envs/python3.5/bin/../include/site/python3.5/mysqlclient
    running install
    running build
    running build_py
    creating build
    creating build/lib.macosx-10.6-intel-3.5
    copying _mysql_exceptions.py -> build/lib.macosx-10.6-intel-3.5
    creating build/lib.macosx-10.6-intel-3.5/MySQLdb
    copying MySQLdb/__init__.py -> build/lib.macosx-10.6-intel-3.5/MySQLdb
    copying MySQLdb/compat.py -> build/lib.macosx-10.6-intel-3.5/MySQLdb
    copying MySQLdb/connections.py -> build/lib.macosx-10.6-intel-3.5/MySQLdb
    copying MySQLdb/converters.py -> build/lib.macosx-10.6-intel-3.5/MySQLdb
    copying MySQLdb/cursors.py -> build/lib.macosx-10.6-intel-3.5/MySQLdb
    copying MySQLdb/release.py -> build/lib.macosx-10.6-intel-3.5/MySQLdb
    copying MySQLdb/times.py -> build/lib.macosx-10.6-intel-3.5/MySQLdb
    creating build/lib.macosx-10.6-intel-3.5/MySQLdb/constants
    copying MySQLdb/constants/__init__.py -> build/lib.macosx-10.6-intel-3.5/MySQLdb/constants
    copying MySQLdb/constants/CLIENT.py -> build/lib.macosx-10.6-intel-3.5/MySQLdb/constants
    copying MySQLdb/constants/CR.py -> build/lib.macosx-10.6-intel-3.5/MySQLdb/constants
    copying MySQLdb/constants/ER.py -> build/lib.macosx-10.6-intel-3.5/MySQLdb/constants
    copying MySQLdb/constants/FIELD_TYPE.py -> build/lib.macosx-10.6-intel-3.5/MySQLdb/constants
    copying MySQLdb/constants/FLAG.py -> build/lib.macosx-10.6-intel-3.5/MySQLdb/constants
    copying MySQLdb/constants/REFRESH.py -> build/lib.macosx-10.6-intel-3.5/MySQLdb/constants
    running build_ext
    building '_mysql' extension
    creating build/temp.macosx-10.6-intel-3.5
    /usr/bin/clang -fno-strict-aliasing -Wsign-compare -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -arch i386 -arch x86_64 -g -Dversion_info=(1,3,10,'final',0) -D__version__=1.3.10 -I/usr/local/Cellar/mysql-connector-c/6.1.10/include -I/Library/Frameworks/Python.framework/Versions/3.5/include/python3.5m -c _mysql.c -o build/temp.macosx-10.6-intel-3.5/_mysql.o
    /usr/bin/clang -bundle -undefined dynamic_lookup -arch i386 -arch x86_64 -g build/temp.macosx-10.6-intel-3.5/_mysql.o -L/usr/local/Cellar/mysql-connector-c/6.1.10/lib -lmysqlclient -lssl -lcrypto -o build/lib.macosx-10.6-intel-3.5/_mysql.cpython-35m-darwin.so
    ld: library not found for -lssl
    clang: error: linker command failed with exit code 1 (use -v to see invocation)
    error: command '/usr/bin/clang' failed with exit status 1
    Running setup.py install for mysqlclient: finished with status 'error'
Cleaning up...
  Removing source in /private/var/folders/1k/_yh_dpzn721401tdqztp_qb40000gn/T/pip-build-32q202m5/mysqlclient
Exception information:
Traceback (most recent call last):
  File "/Users/ning-pc/Envs/python3.5/lib/python3.5/site-packages/pip/basecommand.py", line 215, in main
    status = self.run(options, args)
  File "/Users/ning-pc/Envs/python3.5/lib/python3.5/site-packages/pip/commands/install.py", line 342, in run
    prefix=options.prefix_path,
  File "/Users/ning-pc/Envs/python3.5/lib/python3.5/site-packages/pip/req/req_set.py", line 784, in install
    **kwargs
  File "/Users/ning-pc/Envs/python3.5/lib/python3.5/site-packages/pip/req/req_install.py", line 878, in install
    spinner=spinner,
  File "/Users/ning-pc/Envs/python3.5/lib/python3.5/site-packages/pip/utils/__init__.py", line 707, in call_subprocess
    % (command_desc, proc.returncode, cwd))
pip.exceptions.InstallationError: Command "/Users/ning-pc/Envs/python3.5/bin/python3 -u -c "import setuptools, tokenize;__file__='/private/var/folders/1k/_yh_dpzn721401tdqztp_qb40000gn/T/pip-build-32q202m5/mysqlclient/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /var/folders/1k/_yh_dpzn721401tdqztp_qb40000gn/T/pip-_rn86vr2-record/install-record.txt --single-version-externally-managed --compile --install-headers /Users/ning-pc/Envs/python3.5/bin/../include/site/python3.5/mysqlclient" failed with error code 1 in /private/var/folders/1k/_yh_dpzn721401tdqztp_qb40000gn/T/pip-build-32q202m5/mysqlclient/
@methane

This comment has been minimized.

Copy link
Member

commented May 14, 2017

@ning1022

This comment has been minimized.

Copy link

commented May 14, 2017

@methane Thank you very much .

Collecting mysqlclient
Installing collected packages: mysqlclient
Successfully installed mysqlclient-1.3.10
@tingxin

This comment has been minimized.

Copy link

commented Jun 6, 2017

@methane Hi methane , could you please tell me more about

    ld: library not found for -lssl
    clang: error: linker command failed with exit code 1 (use -v to see invocation)
    error: command '/usr/bin/clang' failed with exit status 1

i run the brew info openssl, but still don't have any idea ! the issue still exist:(

@methane

This comment has been minimized.

Copy link
Member

commented Jun 6, 2017

Read brew info openssl output.

@methane

This comment has been minimized.

Copy link
Member

commented Jun 7, 2017

it seems i need add some environment var, i added it to my local, and i installed python3 certificate, but it does not work.

Write what you did and saw actually?
How set environment and install?
What error? full stacktrace??
Do you really read #169 (comment) ?

I'm not free tech support. Please don't rob my time by such a very incomplete question!

@methane

This comment has been minimized.

Copy link
Member

commented Jun 7, 2017

Now i have no idea :(

Huh? You said:

it seems i need add some environment var, i added it to my local,

What you did???
Did you confirmed you correctly configured environment variable????

You must read this article: https://medium.com/@methane/why-you-must-not-ask-questions-on-github-issues-51d741d83fde

@methane

This comment has been minimized.

Copy link
Member

commented Jun 7, 2017

OK. You didn't know even how to set environment variables.
Issue tracker is not place for answering such an easy question.

@tingxin

This comment has been minimized.

Copy link

commented Jun 7, 2017

I follow those step:

i) modify file: /usr/local/bin/mysql_config (which mysql_config)
origin:

# Create options 
libs="-L$pkglibdir" 
libs="$libs -l "

modified to

# Create options
libs="-L$pkglibdir" 
libs="$libs -lmysqlclient -lssl -lcrypto"

ii)add environment veriables(brew info openssl)

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

iii)pip3 install mysqlclient

if you still meet the issue:

    ld: library not found for -lssl
    clang: error: linker command failed with exit code 1 (use -v to see invocation)
    error: command '/usr/bin/clang' failed with exit status 1

i fix it by install PyMySQL

pip3 install PyMySQL

Hope this help later-comers:

@methane

This comment has been minimized.

Copy link
Member

commented Jun 7, 2017

Your info will confuse later-comers.

Your information is incomplete. But here is not place to teach beginners.
Go user forum or stack overflow or other community.
Some kindly people may help you.

@tingxin

This comment has been minimized.

Copy link

commented Jun 7, 2017

@methane sure, but i hope sometime you will be a kindly man

@methane

This comment has been minimized.

Copy link
Member

commented Jun 7, 2017

Ya, I only dislike using issue tracker as Q&A site.
Issue tracker is place to move project forward, maintain product high quality.
So I think using issue tracker as user forum disturb project development and quality.

I will be kind in other places.

@tingxin

This comment has been minimized.

Copy link

commented Jun 7, 2017

@methane for a user, he just want to install and use your product, if this product depend on somethings else, i
think it should be list in the readme or some files. if one issue closed, it means it won't be happen in later. i did not find those information now.
in your mind, it looks the install issue is not a question of a product.

i just a user of mysqlclient, but i need to know so much tech things then i can install it yet.

@methane

This comment has been minimized.

Copy link
Member

commented Jun 7, 2017

@tingxin
Your issue seems very basic Unix operation.
I think all issues about installation are answered already.
If you don't think so, you should write complete issue report. Current your comments are too incomplete

  • You didn't write complete log (you can put it on gist or somewhere and write link).
  • You didn't show how you set environment variable. (wrote export ... to bashrc? or run it in shell right before running pip?)
  • You didn't wrote how you confirm you set environment variable successfully. (run env commnad before pip).
  • You didn't wrote why linker failed. (e.g. ls /usr/local/opt/openssl/lib).

Have you really read my post?
I receives doezen mails a week about generic Unix or MySQL question, not mysqlclient-python issue.
I'm very frustrated.

Why should I read such mails and take time to reply?
I'm not teacher of Unix or MySQL. I maintain some other projects. I'm very very busy. I have two years daughter. Teaching to you is more important than playing with my daughter?

@elangelgris

This comment has been minimized.

Copy link

commented Jun 8, 2017

Hi @janikarh, i had the same error minutes ago. I solved it doing this:

$ brew uninstall mysql
$ brew install mysql-connector-c
$ brew unlink mysql-connector-c
$ brew install mysql
$ pip install mysql-python

From: https://stackoverflow.com/questions/40587558/error-installing-mysql-python-library-not-found-for-lssl

Good luck.

@methane

This comment has been minimized.

Copy link
Member

commented Jun 8, 2017

Please stop reduce S/N ratio!
Bug in MySQL Connector/C is useful information. This issue is for it.

link error is totally different problem, and link error message is just a noise unless you wrote
clang command above the link error.
None of you write enough information about link error. Now 70% of this thread is noise!!!

If you can write complete "issue report", file a new issue.
Otherwise, go somewhere else!!

@PyMySQL PyMySQL locked and limited conversation to collaborators Jun 8, 2017

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.