ImportError: No module named _mysql_exceptions

121 views
Skip to first unread message

Cat22

unread,
Feb 29, 2020, 3:06:10 PM2/29/20
to weewx-user
Hi,
weewx 3.9.2
  I am adding the mysql capability to my weewx install and having some trouble getting it going. (sqlite is working though)
I have verified the username and password work ok from a command prompt and the table(s) are there imported from a previous system and they are readable 
The issue sems to be the proper python files but I have installed what looked right (I am on openSuse Tumbleweed x86_64)
TIA
Cat22
Here is the relevant parts of my weewx.conf:

#   This section binds a data store to a database.

[DataBindings]
   
   
[[wx_binding]]
       
# The database must match one of the sections in [Databases].
       
# This is likely to be the only option you would want to change.
       
#database = archive_sqlite
        database
= archive_mysql
       
# The name of the table within the database
        table_name
= archive
       
# The manager handles aggregation of data for historical summaries
        manager
= weewx.wxmanager.WXDaySummaryManager
       
# The schema defines the structure of the database.
       
# It is *only* used when the database is created.
        schema
= schemas.wview.schema

##############################################################################

#   This section defines various databases.

[Databases]
   
   
# A SQLite database is simply a single file
   
[[archive_sqlite]]
        database_type
= SQLite
        database_name
= weewx.sdb
   
   
# MySQL
   
[[archive_mysql]]
        database_type
= MySQL
        database_name
= weewx

##############################################################################

#   This section defines defaults for the different types of databases.

[DatabaseTypes]
   
   
# Defaults for SQLite databases
   
[[SQLite]]
        driver
= weedb.sqlite
       
# Directory in which the database files are located
        SQLITE_ROOT
= %(WEEWX_ROOT)s/archive
   
   
# Defaults for MySQL databases
   
[[MySQL]]
        driver
= weedb.mysql
       
# The host where the database is located
        host
= localhost
       
# The user name for logging in to the host
        user
= <user>
       
# The password for the user name
        password
= <password>



And here is the error from journalctl:

 engine: Using Python 2.7.17 (default, Oct 24 2019, 12:43:41) [GCC]
 engine
: Platform Linux-5.4.14-x86_64-with-glibc2.2.5
 engine
: Locale is 'en_US.UTF-8'
 engine
: Using configuration file /usr/local/bin/weewx/weewx.conf
 engine
: Loading station type Vantage (weewx.drivers.vantage)
 engine
: StdConvert target unit is 0x1
 wxcalculate
: The following values will be calculated: barometer=prefer_hardware, windchill=prefer_hardware, dewpoint=prefer_hardware, appTemp=prefer_hardware, rainRate=prefer_hardware, windrun=prefer_hardware, heatindex=prefer_hardware>
 wxcalculate
: The following algorithms will be used for calculations: altimeter=aaNOAA, maxSolarRad=RS
 engine
: Archive will use data binding wx_binding
 engine
: Record generation will be attempted in 'hardware'
 engine
: Using archive interval of 300 seconds (specified by hardware)
 engine
: Caught unrecoverable exception in engine:
     
****  No module named _mysql_exceptions
     
****  Traceback (most recent call last):
     
****    File "/usr/local/bin/weewx/bin/weewx/engine.py", line 888, in main
     
****      engine = engine_class(config_dict)
     
****    File "/usr/local/bin/weewx/bin/weewx/engine.py", line 78, in __init__
 
Traceback (most recent call last):
   
File "/usr/local/bin/weewx/bin/weewxd", line 64, in <module>
      weewx
.engine.main(options, args)
   
File "/usr/local/bin/weewx/bin/weewx/engine.py", line 888, in main
     
****      self.loadServices(config_dict)
      engine
= engine_class(config_dict)
   
File "/usr/local/bin/weewx/bin/weewx/engine.py", line 78, in __init__
     
self.loadServices(config_dict)
   
File "/usr/local/bin/weewx/bin/weewx/engine.py", line 142, in loadServices
     
self.service_obj.append(weeutil.weeutil._get_object(svc)(self, config_dict))
   
File "/usr/local/bin/weewx/bin/weewx/engine.py", line 500, in __init__
     
self.setup_database(config_dict)
   
File "/usr/local/bin/weewx/bin/weewx/engine.py", line 608, in setup_database
     
****    File "/usr/local/bin/weewx/bin/weewx/engine.py", line 142, in loadServices
      dbmanager
= self.engine.db_binder.get_manager(self.data_binding, initialize=True)
   
File "/usr/local/bin/weewx/bin/weewx/manager.py", line 872, in get_manager
     
self.manager_cache[data_binding] = open_manager(manager_dict, initialize)
   
File "/usr/local/bin/weewx/bin/weewx/manager.py", line 1021, in open_manager
     
****      self.service_obj.append(weeutil.weeutil._get_object(svc)(self, config_dict))
      manager_dict
['schema'])
   
File "/usr/local/bin/weewx/bin/weewx/manager.py", line 128, in open_with_create
      connection
= weedb.connect(database_dict)
   
File "/usr/local/bin/weewx/bin/weedb/__init__.py", line 86, in connect
      __import__
(db_dict['driver'])
   
File "/usr/local/bin/weewx/bin/weedb/mysql.py", line 11, in <module>
     
from _mysql_exceptions import DatabaseError, IntegrityError, ProgrammingError, OperationalError
     
****    File "/usr/local/bin/weewx/bin/weewx/engine.py", line 500, in __init__
 
ImportError: No module named _mysql_exceptions
     
****      self.setup_database(config_dict)
     
****    File "/usr/local/bin/weewx/bin/weewx/engine.py", line 608, in setup_database
     
****      dbmanager = self.engine.db_binder.get_manager(self.data_binding, initialize=True)
     
****    File "/usr/local/bin/weewx/bin/weewx/manager.py", line 872, in get_manager
     
****      self.manager_cache[data_binding] = open_manager(manager_dict, initialize)
     
****    File "/usr/local/bin/weewx/bin/weewx/manager.py", line 1021, in open_manager
     
****      manager_dict['schema'])
     
****    File "/usr/local/bin/weewx/bin/weewx/manager.py", line 128, in open_with_create
     
****      connection = weedb.connect(database_dict)
     
****    File "/usr/local/bin/weewx/bin/weedb/__init__.py", line 86, in connect
     
****      __import__(db_dict['driver'])
     
****    File "/usr/local/bin/weewx/bin/weedb/mysql.py", line 11, in <module>
     
****      from _mysql_exceptions import DatabaseError, IntegrityError, ProgrammingError, OperationalError
     
****  ImportError: No module named _mysql_exceptions
     
****  Exiting.
 systemd
[1]: weewx.service: Failed with result 'exit-code'.



Thomas Keffer

unread,
Mar 1, 2020, 9:28:28 AM3/1/20
to weewx-user
Which platform are you using?

Looks like you did some kind of non-standard install of WeeWX, which is fine. I doubt it is the problem.

However, how did you install the mysql driver? 

-tk

--
You received this message because you are subscribed to the Google Groups "weewx-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to weewx-user+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/weewx-user/690040c1-6b18-43b6-a1f1-f34cddd45256%40googlegroups.com.

Cat22

unread,
Mar 2, 2020, 12:34:13 AM3/2/20
to weewx-user


On Sunday, March 1, 2020 at 6:28:28 AM UTC-8, Thomas Keffer wrote:
Which platform are you using?

Looks like you did some kind of non-standard install of WeeWX, which is fine. I doubt it is the problem.

However, how did you install the mysql driver? 

-tk
I see that weewx/bin/weedb/mysql.py is not right, the date is out of sync. If I do a weewx upgrade will that replace all the files such as mysql.py?

Cat22

unread,
Mar 2, 2020, 12:54:52 AM3/2/20
to weewx-user
I did an upgrade and i still cant get mysql to work
I can telnet into mysql on localhost ok and from a remote machine using the IP of the system with mysql on it
I wonder, what does mysql.py use for a connection ip? Hopefully its localhost

Cat22

unread,
Mar 2, 2020, 1:55:47 AM3/2/20
to weewx-user
So, as near as I can tell I am missing a module called _mysql_exceptions and I can not find that module to install it
Another question i have is:
Is wewx supposed to run under python 2.7 or on python 3.x?
It seems its 2.7 to me, but I am no python programmer.
In any case pip2 pip2.7 and pip3  cant seem to find the module at all
Do any of you have weewx running with mysql?
I'm starting to wonder if its a bug in weewx code or not.

Andrew Milner

unread,
Mar 2, 2020, 2:21:09 AM3/2/20
to weewx-user
You have not answered Tom's questions:
What platform?
How did you install mysql driver?

Yes, there are many of us running weewx with mysql or mariadb

weewx 3.9 runs under python 2.7, weewx 4 (not yet released) will run under python 3

Cat22

unread,
Mar 2, 2020, 5:12:09 AM3/2/20
to weewx-user
I am openSuse Tumbleweed (x86_64) and I had installed PyMySQL version 0.9.3-1.4 and just now i saw python2-PyMySQL 2.1.7-2.5 and tried that and it seems the 'cant find module'  message went away
it seems i now have a different issue tho, so I have a question, if I dont have the weewx database created in mysql will weewx create it?
e.g can i change the line in
  [[archive_mysql]]
        database_type = MySQL
        database_name = weewx
where database_name is weewx to something like database_name=wx ?
if i do that will weewx create the database wx and populate it with the necessary tables?

Andrew Milner

unread,
Mar 2, 2020, 5:59:18 AM3/2/20
to weewx-user
yes, if you have created a weewx user with correct permissions as described in the weewx documentation

gjr80

unread,
Mar 2, 2020, 7:19:55 AM3/2/20
to weewx-user
On Monday, 2 March 2020 20:12:09 UTC+10, Cat22 wrote:
I am openSuse Tumbleweed (x86_64) and I had installed PyMySQL version 0.9.3-1.4 and just now i saw python2-PyMySQL 2.1.7-2.5 and tried that and it seems the 'cant find module'  message went away

Not somewhere you would normally go looking but It all seems rather obvious given this comment in mysql.py. It's not covered specifically (for Suse) in the WeeWX documentation as I guess the assumption is that if you are advanced enough to be configuring MySQL you should be advanced enough to know which package to install to obtain the MySQLdb python package.

Gary

Cat22

unread,
Mar 3, 2020, 9:58:55 PM3/3/20
to weewx-user
Well, I guess I am SOL.
Reply all
Reply to author
Forward
0 new messages