pattern icon indicating copy to clipboard operation
pattern copied to clipboard

SQL config error on Mac OSX installation

Open alvations opened this issue 7 years ago • 11 comments

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/

alvations avatar Jan 03 '18 02:01 alvations

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).

derNarr avatar Jan 04 '18 10:01 derNarr

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

curiousrohan avatar Mar 03 '18 15:03 curiousrohan

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

ghost avatar May 20 '18 21:05 ghost

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 avatar Oct 22 '18 12:10 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.

evanmiltenburg avatar Oct 23 '18 17:10 evanmiltenburg

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.

falconair avatar Jun 19 '19 15:06 falconair

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

evanmiltenburg avatar Jun 19 '19 15:06 evanmiltenburg

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

cheneypinata avatar Jun 20 '19 19:06 cheneypinata

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

vizzerdrix55 avatar Jun 25 '19 09:06 vizzerdrix55

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

flekschas avatar Aug 27 '19 23:08 flekschas

I solved the problem using brew install mysql

as mentioned above! thanks

TailaneBrito avatar Nov 20 '19 15:11 TailaneBrito