No module named MySQL.db (OSX 10.11.6 (El Cap))

1,193 views
Skip to first unread message

Dan'l B

unread,
Dec 3, 2016, 9:19:33 AM12/3/16
to weewx-user
I'm testing the MySQL archiving to a remote host, and getting this error:

3/12/2016 09:07:21.209 weewx[78560]:     ****  No module named MySQLdb
3/12/2016 09:07:21.212 weewx[78560]:     ****  Traceback (most recent call last):
3/12/2016 09:07:21.212 weewx[78560]:     ****    File "/Users/Shared/weewx/bin/weewx/engine.py", line 838, in main
3/12/2016 09:07:21.213 weewx[78560]:     ****      engine = engine_class(config_dict)
3/12/2016 09:07:21.213 weewx[78560]:     ****    File "/Users/Shared/weewx/bin/weewx/engine.py", line 76, in __init__
3/12/2016 09:07:21.213 weewx[78560]:     ****      self.loadServices(config_dict)
3/12/2016 09:07:21.213 weewx[78560]:     ****    File "/Users/Shared/weewx/bin/weewx/engine.py", line 140, in loadServices
3/12/2016 09:07:21.213 weewx[78560]:     ****      self.service_obj.append(weeutil.weeutil._get_object(svc)(self, config_dict))
3/12/2016 09:07:21.213 weewx[78560]:     ****    File "/Users/Shared/weewx/bin/weewx/engine.py", line 483, in __init__
3/12/2016 09:07:21.213 weewx[78560]:     ****      self.setup_database(config_dict)
3/12/2016 09:07:21.213 weewx[78560]:     ****    File "/Users/Shared/weewx/bin/weewx/engine.py", line 581, in setup_database
3/12/2016 09:07:21.214 weewx[78560]:     ****      dbmanager = self.engine.db_binder.get_manager(self.data_binding, initialize=True)
3/12/2016 09:07:21.214 weewx[78560]:     ****    File "/Users/Shared/weewx/bin/weewx/manager.py", line 824, in get_manager
3/12/2016 09:07:21.214 weewx[78560]:     ****      self.manager_cache[data_binding] = open_manager(manager_dict, initialize)
3/12/2016 09:07:21.214 weewx[78560]:     ****    File "/Users/Shared/weewx/bin/weewx/manager.py", line 973, in open_manager
3/12/2016 09:07:21.214 weewx[78560]:     ****      manager_dict['schema'])
3/12/2016 09:07:21.214 weewx[78560]:     ****    File "/Users/Shared/weewx/bin/weewx/manager.py", line 125, in open_with_create
3/12/2016 09:07:21.215 weewx[78560]:     ****      connection = weedb.connect(database_dict)
3/12/2016 09:07:21.215 weewx[78560]:     ****    File "/Users/Shared/weewx/bin/weedb/__init__.py", line 60, in connect
3/12/2016 09:07:21.215 weewx[78560]:     ****      __import__(db_dict['driver'])
3/12/2016 09:07:21.215 weewx[78560]:     ****    File "/Users/Shared/weewx/bin/weedb/mysql.py", line 10, in <module>
3/12/2016 09:07:21.215 weewx[78560]:     ****      import MySQLdb
3/12/2016 09:07:21.215 weewx[78560]:     ****  ImportError: No module named MySQLdb


I gather from a previous thread here


that I need to install two items:

You need to install the client interfaces to MySQL. 

sudo apt-get install mysql-client
sudo apt-get install python-mysqldb

On my OSX 10.11.6 (El Cap) system this would be via pip, correct?

Macmini:/Users/Shared/weewx$ sudo -H pip install mysql-client

Password:

Collecting mysql-client

  Could not find a version that satisfies the requirement mysql-client (from versions: )

No matching distribution found for mysql-client

-------------------------------------------------------------------------------------------------------------------------------------- 08:18:27

Macmini:/Users/Shared/weewx$ port search mysql-client

No match for mysql-client found

-------------------------------------------------------------------------------------------------------------------------------------- 08:18:50

Macmini:/Users/Shared/weewx$ port search python-mysqldb

No match for python-mysqldb found

-------------------------------------------------------------------------------------------------------------------------------------- 08:20:01

Macmini:/Users/Shared/weewx$ sudo -H pip install python-mysqldb

Password:

Collecting python-mysqldb

  Could not find a version that satisfies the requirement python-mysqldb (from versions: )

No matching distribution found for python-mysqldb 

Am I not doing this correctly? 

Andrew Milner

unread,
Dec 3, 2016, 9:23:57 AM12/3/16
to weewx-user

Dan'l B

unread,
Dec 3, 2016, 2:32:02 PM12/3/16
to weewx-user
On Saturday, December 3, 2016 at 9:23:57 AM UTC-5, Andrew Milner wrote:
I'm testing the MySQL archiving to a remote host, and getting this error:

3/12/2016 09:07:21.209 weewx[78560]:     ****  No module named MySQLdb
3/12/2016 09:07:21.213 weewx[78560]:     ****      self.service_obj.append(weeutil.weeutil._get_object(svc)(self, config_dict))
3/12/2016 09:07:21.214 weewx[78560]:     ****      self.manager_cache[data_binding] = open_manager(manager_dict, initialize)
3/12/2016 09:07:21.215 weewx[78560]:     ****      connection = weedb.connect(database_dict)

I take it you mean do the install of MySQL on the Mac. I did so (I am so used to using a MAMP stack that I forget about these things) but it has had no effect. Server is running, did a full re-boot of the mac. Same error

mwall

unread,
Dec 3, 2016, 2:54:40 PM12/3/16
to weewx-user


On Saturday, December 3, 2016 at 9:19:33 AM UTC-5, Dan'l B wrote:
I gather from a previous thread here


that I need to install two items:

You need to install the client interfaces to MySQL. 

sudo apt-get install mysql-client
sudo apt-get install python-mysqldb

On my OSX 10.11.6 (El Cap) system this would be via pip, correct?

Am I not doing this correctly? 

i think the mysql package name for pip is mysql-python:

sudo pip install mysql-python

m
 

Dan'l B

unread,
Dec 3, 2016, 7:15:48 PM12/3/16
to weewx-user

house@Houses-Macmini:/Users/shared/weewx$ sudo -H pip install mysql-python

Password:

Collecting mysql-python

  Downloading MySQL-python-1.2.5.zip (108kB)

    100% |████████████████████████████████| 112kB 539kB/s 

    Complete output from command python setup.py egg_info:

    sh: mysql_config: command not found

    Traceback (most recent call last):

      File "<string>", line 1, in <module>

      File "/private/tmp/pip-build-XCRGc0/mysql-python/setup.py", line 17, in <module>

        metadata, options = get_config()

      File "setup_posix.py", line 43, in get_config

        libs = mysql_config("libs_r")

      File "setup_posix.py", line 25, in mysql_config

        raise EnvironmentError("%s not found" % (mysql_config.path,))

    EnvironmentError: mysql_config not found

    

    ----------------------------------------

Command "python setup.py egg_info" failed with error code 1 in /private/tmp/pip-build-XCRGc0/mysql-python/ 

mwall

unread,
Dec 4, 2016, 12:34:30 PM12/4/16
to weewx-user
On Saturday, December 3, 2016 at 7:15:48 PM UTC-5, Dan'l B wrote:
house@Houses-Macmini:/Users/shared/weewx$ sudo -H pip install mysql-python

Password:

Collecting mysql-python

  Downloading MySQL-python-1.2.5.zip (108kB)

    100% |████████████████████████████████| 112kB 539kB/s 

    Complete output from command python setup.py egg_info:

    sh: mysql_config: command not found

    Traceback (most recent call last):

      File "<string>", line 1, in <module>

      File "/private/tmp/pip-build-XCRGc0/mysql-python/setup.py", line 17, in <module>

        metadata, options = get_config()

      File "setup_posix.py", line 43, in get_config

        libs = mysql_config("libs_r")

      File "setup_posix.py", line 25, in mysql_config

        raise EnvironmentError("%s not found" % (mysql_config.path,))

    EnvironmentError: mysql_config not found

    

    ----------------------------------------

Command "python setup.py egg_info" failed with error code 1 in /private/tmp/pip-build-XCRGc0/mysql-python/ 

apparently the python wrapper mysql-python is not pure python, and depends on a local mysql installation.

so you'll have to install mysql too - use a guide like this:

https://wpguru.co.uk/2015/11/how-to-install-mysql-on-mac-os-x-el-capitan/

m

Dan'l B

unread,
Dec 4, 2016, 4:50:36 PM12/4/16
to weewx-user
Well, I had installed MySQL and was running it and will try again but it's annoying as it then blocks port 3306 which is used by the MySQL install in my MAMP stack, which I use quite often. And I guess that python install can't see the MAMP MySQL unless I do something with the $PATH.

Thanks, 
Reply all
Reply to author
Forward
0 new messages