import mysql in python file fails
sklist at kitterman.com
Sat Feb 5 15:12:11 UTC 2022
On Saturday, February 5, 2022 8:54:58 AM EST dy1977--- via Unbound-users
> I have been using unbound with a python file for years in Debian 10.
> I am installing the system in Debian 11 but "import mysql" fails.
> mysql.connector was properly installed, and if I run directly the python
> file, it does not provoque any error. Here is the code
> import csv, json, time, os, sys
> from collections import OrderedDict
> import mysql
> import mysql.connector as database
> But when I try to start unbound, the following error happens :
> Feb 5 14:24:38 Idefix-APU2 systemd: Starting Unbo
> und DNS server...
> Feb 5 14:24:38 Idefix-APU2 unbound: [32270:0] notice: init module 0:
> Feb 5 14:24:38 Idefix-APU2 unbound: [32270:0] notice: init module 1: python
> Feb 5 14:24:38 Idefix-APU2 unbound: Traceback (most recent call
> Feb 5 14:24:38 Idefix-APU2 unbound: File
> "/usr/lib/idefix/unbound-filter.py", line 20, in <module>
> Feb 5 14:24:38 Idefix-APU2 unbound: import mysql
> Feb 5 14:24:38 Idefix-APU2 unbound: ModuleNotFoundError: No
> module named 'mysql'
> Feb 5 14:24:38 Idefix-APU2 unbound: [32270:0] error: pythonmod: can't
> parse Python script /usr/lib/idefix/unbound-filter.py
> I have updated the sys.path.append to the new python version. In this
> directory there is a 'mysql' subdirectory, and in this subdirectory
> there is a __init__.py file. I do not understand what is missing.
If the module is installed correctly you should not have to manually modify
sys.path. I would look into whatever caused you to consider doing that and
try and address that. That may be your root cause issue.
On Debian systems with the Debian provided python3, /usr/local/lib/python3.X/
dist-packages is already in the system path.
More information about the Unbound-users