Skip to content

SQL config error on Mac OSX installation #203

@alvations

Description

@alvations

With Python3 and pip3 on Mac OSX, there's a sql config error

$ sudo pip3 install -U https://github.com/clips/pattern/archive/development.zip

Collecting https://github.com/clips/pattern/archive/development.zip
  Downloading https://github.com/clips/pattern/archive/development.zip (24.8MB)
    100% |████████████████████████████████| 24.8MB 40kB/s 
Collecting future (from Pattern==2.6)
  Downloading future-0.16.0.tar.gz (824kB)
    100% |████████████████████████████████| 829kB 850kB/s 
Collecting backports.csv (from Pattern==2.6)
  Downloading backports.csv-1.0.5-py2.py3-none-any.whl
Collecting mysqlclient (from Pattern==2.6)
  Downloading mysqlclient-1.3.12.tar.gz (89kB)
    100% |████████████████████████████████| 92kB 2.5MB/s 
    Complete output from command python setup.py egg_info:
    /bin/sh: mysql_config: command not found
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/private/tmp/pip-build-c2voibrz/mysqlclient/setup.py", line 17, in <module>
        metadata, options = get_config()
      File "/private/tmp/pip-build-c2voibrz/mysqlclient/setup_posix.py", line 44, in get_config
        libs = mysql_config("libs_r")
      File "/private/tmp/pip-build-c2voibrz/mysqlclient/setup_posix.py", line 26, in mysql_config
        raise EnvironmentError("%s not found" % (mysql_config.path,))
    OSError: mysql_config not found
    
    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /private/tmp/pip-build-c2voibrz/mysqlclient/

Activity

derNarr

derNarr commented on Jan 4, 2018

@derNarr

I had the same error in linux (debian 9) and could solve it by installing mysql_config over the package manager with sudo apt-get install libmariadbclient-dev (this is the mariadb drop-in replacement for mysql_config).

This might solve you problem: https://stackoverflow.com/questions/25459386/mac-os-x-environmenterror-mysql-config-not-found (I cannot judge if this is the proper way to install mysql_config on your system).

curiousrohan

curiousrohan commented on Mar 3, 2018

@curiousrohan

I had the same error in MacOS High Sierra
Doing:
brew install mysql
PATH=$PATH:/usr/local/mysql/bin
solved the problem

ghost

ghost commented on May 20, 2018

@ghost

I found downloading Pattern from source allows you to use Pattern without worrying about SQL, until you actually need to use the database feature.

evanmiltenburg

evanmiltenburg commented on Oct 22, 2018

@evanmiltenburg

I got the same error as @alvations using the version from PyPI:

Emiel$ pip install pattern
Collecting pattern
  Downloading https://files.pythonhosted.org/packages/1e/07/b0e61b6c818ed4b6145fe01d1c341223aa6cfbc3928538ad1f2b890924a3/Pattern-3.6.0.tar.gz (22.2MB)
    100% |████████████████████████████████| 22.3MB 1.4MB/s
Collecting future (from pattern)
  Downloading https://files.pythonhosted.org/packages/00/2b/8d082ddfed935f3608cc61140df6dcbf0edea1bc3ab52fb6c29ae3e81e85/future-0.16.0.tar.gz (824kB)
    100% |████████████████████████████████| 829kB 18.4MB/s
Collecting backports.csv (from pattern)
  Downloading https://files.pythonhosted.org/packages/71/f7/5db9136de67021a6dce4eefbe50d46aa043e59ebb11c83d4ecfeb47b686e/backports.csv-1.0.6-py2.py3-none-any.whl
Collecting mysqlclient (from pattern)
  Downloading https://files.pythonhosted.org/packages/ec/fd/83329b9d3e14f7344d1cb31f128e6dbba70c5975c9e57896815dbb1988ad/mysqlclient-1.3.13.tar.gz (90kB)
    100% |████████████████████████████████| 92kB 5.5MB/s
    Complete output from command python setup.py egg_info:
    /bin/sh: mysql_config: command not found
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/private/var/folders/p0/dfmctn613mj8l2q3rpksnsz80000gn/T/pip-install-xcr99rmb/mysqlclient/setup.py", line 18, in <module>
        metadata, options = get_config()
      File "/private/var/folders/p0/dfmctn613mj8l2q3rpksnsz80000gn/T/pip-install-xcr99rmb/mysqlclient/setup_posix.py", line 53, in get_config
        libs = mysql_config("libs_r")
      File "/private/var/folders/p0/dfmctn613mj8l2q3rpksnsz80000gn/T/pip-install-xcr99rmb/mysqlclient/setup_posix.py", line 28, in mysql_config
        raise EnvironmentError("%s not found" % (mysql_config.path,))
    OSError: mysql_config not found
evanmiltenburg

evanmiltenburg commented on Oct 23, 2018

@evanmiltenburg

Because I don't need the database feature, I bluntly solved the issue by commenting out line 140 in setup.py. So this:

    install_requires = [
        "future",
        "backports.csv",
        "mysqlclient",
        "beautifulsoup4",
        "lxml",
        "feedparser",
        "pdfminer" if sys.version < "3" else "pdfminer.six",
        "numpy",
        "scipy",
        "nltk",
        "python-docx",
        "cherrypy",
        "requests"
    ],

Becomes:

    install_requires = [
        "future",
        "backports.csv",
#        "mysqlclient",
        "beautifulsoup4",
        "lxml",
        "feedparser",
        "pdfminer" if sys.version < "3" else "pdfminer.six",
        "numpy",
        "scipy",
        "nltk",
        "python-docx",
        "cherrypy",
        "requests"
    ],

This way, python setup.py install runs without any errors. It's not pretty but it works.

falconair

falconair commented on Jun 19, 2019

@falconair

I am coming across this issue when I install pattern via pip (on python 3.6). I am installing this library as a dependency for gensim. I just need pattern for lemmatization features, is a mysql installation really required?

Several people have suggested installing mysql via brew or apt, but I need to install this library in an environment where things are pretty locked down. Not having a mysql dependency will make this much easier.

evanmiltenburg

evanmiltenburg commented on Jun 19, 2019

@evanmiltenburg

No. Mysql is needed for storing results. My solution above would work for you as well.

cheneypinata

cheneypinata commented on Jun 20, 2019

@cheneypinata

Having the same issue with OS Mojave 10.15.5 and the workaround from @curiousrohan seemed to work.

vizzerdrix55

vizzerdrix55 commented on Jun 25, 2019

@vizzerdrix55

I had the same error in MacOS High Sierra
Doing:
brew install mysql
PATH=$PATH:/usr/local/mysql/bin
solved the problem

Performing these lines in terminal worked also for solving the problem in Jupyter Notebook 5.7.4 with Python 3.7.1 on macOS Mojave

flekschas

flekschas commented on Aug 27, 2019

@flekschas

In case you don't want to install mysql system-wide, you can easily create a Conda environment. The following works for me:

name: pattern
channels:
  - conda-forge

dependencies:
  - python>=3.7
  - mysql # Needed by pattern
  - pip
  - pip:
    - pattern==3.6
TailaneBrito

TailaneBrito commented on Nov 20, 2019

@TailaneBrito

I solved the problem using
brew install mysql

as mentioned above! thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @falconair@derNarr@flekschas@alvations@evanmiltenburg

        Issue actions

          SQL config error on Mac OSX installation · Issue #203 · clips/pattern