Hello Gang! I'm grateful once again for the advice to use MySQL over Postgres. It's been a pretty smooth experience so far. Unfortunately I had to migrate to a different host and have been getting an undefined variable error.

Mysql is Running. I used the package manager to get python-mysql.connector installed. And yet I keep getting an undefined variable error.

Here is the output:

Exception creating initial db connection
Error:  module 'ssl' has no attribute 'wrap_socket'
Error type:  <class 'AttributeError'>

Here is some test code if you need to replicate it:

import base64
import mysql.connector as mysql
try:
    connection=mysql.connect( host="localhost", database="iheartdaniweb", user="funuser", password="supersekritpass") 
except Exception as error:
    print("Exception creating initial db connection")
    print("Error: ", error)
    print("Error type: ", type(error))
connection.autocommit=True

Thanks in advance gang! Unfortunately the interwebs were no help with this one or I wouldn't bother you guys! Thanks again!! !!

I tried this on a mint system, a debian system and an ubuntu system with the same error. Should I just bite the bullet and maybe migrate to red hat? That would be skurry but perhaps necessary??

@Salem

Thanks!

OK, from my old working system I got:

apturl                 0.5.2
attrs                  21.2.0
Automat                20.2.0
bcrypt                 3.2.0
beautifulsoup4         4.10.0
blinker                1.4
Brlapi                 0.8.3
certifi                2020.6.20
chardet                4.0.0
click                  8.0.3
colorama               0.4.4
command-not-found      0.3
constantly             15.1.0
cryptography           3.4.8
cupshelpers            1.0
dbus-python            1.2.18
debtags                2.1
defer                  1.0.6
deluge                 2.0.3
distro                 1.7.0
distro-info            1.1+ubuntu0.2
GeoIP                  1.3.2
html5lib               1.1
httplib2               0.20.2
hyperlink              21.0.0
idna                   3.3
importlib-metadata     4.6.4
incremental            21.3.0
jeepney                0.7.1
keyring                23.5.0
language-selector      0.1
launchpadlib           1.10.16
lazr.restfulclient     0.14.4
lazr.uri               1.0.6
libtorrent             2.0.5-build-libtorrent-rasterbar-qrM5vM-libtorrent-rasterbar-2.0.5-bindings-python
louis                  3.20.0
lxml                   4.8.0
macaroonbakery         1.3.1
Mako                   1.1.3
MarkupSafe             2.0.1
more-itertools         8.10.0
mysql-connector-python 8.0.15
netifaces              0.11.0
numpy                  1.21.5
oauthlib               3.2.0
olefile                0.46
onioncircuits          0.7
pdfkit                 1.0.0
pexpect                4.8.0
Pillow                 9.0.1
pip                    22.0.2
protobuf               3.12.4
ptyprocess             0.7.0
pyasn1                 0.4.8
pyasn1-modules         0.2.1
pycairo                1.20.1
pycountry              20.7.3
pycryptodomex          3.11.0
pycups                 2.0.1
pygame                 2.1.2
PyGObject              3.42.1
PyHamcrest             2.0.2
PyJWT                  2.3.0
pymacaroons            0.13.0
PyNaCl                 1.5.0
pyOpenSSL              21.0.0
pyparsing              2.4.7
pyRFC3339              1.1
python-apt             2.4.0+ubuntu3
python-dateutil        2.8.1
python-debian          0.1.43+ubuntu1.1
pytz                   2022.1
pyxattr                0.7.2
pyxdg                  0.27
PyYAML                 5.4.1
rencode                1.0.6
reportlab              3.6.8
requests               2.25.1
scour                  0.38.2
SecretStorage          3.3.1
service-identity       18.1.0
setproctitle           1.2.2
setuptools             59.6.0
six                    1.16.0
soupsieve              2.3.1
stem                   1.8.0
systemd-python         234
Twisted                22.1.0
ubuntu-drivers-common  0.0.0
ubuntu-pro-client      8001
ufw                    0.36.1
unattended-upgrades    0.1
urllib3                1.26.5
vboxapi                1.0
wadllib                1.3.6
webencodings           0.5.1
wheel                  0.37.1
xdg                    5
xkit                   0.0.0
youtube-dl             2021.12.17
zipp                   1.0.0
zope.interface         5.4.0

And now from my new system I have:

attrs                  23.2.0
Babel                  2.10.3
bcc                    0.29.1
blinker                1.7.0
certifi                2023.11.17
chardet                5.2.0
click                  8.1.6
cloud-init             24.1.3
colorama               0.4.6
configobj              5.0.8
cryptography           41.0.7
dbus-python            1.3.2
distro                 1.9.0
distro-info            1.7+build1
httplib2               0.20.4
idna                   3.6
Jinja2                 3.1.2
jsonpatch              1.32
jsonpointer            2.0
jsonschema             4.10.3
launchpadlib           1.11.0
lazr.restfulclient     0.14.6
lazr.uri               1.0.6
markdown-it-py         3.0.0
MarkupSafe             2.1.5
mdurl                  0.1.2
mysql-connector-python 8.0.15
netaddr                0.8.0
netifaces              0.11.0
oauthlib               3.2.2
pip                    24.0
protobuf               4.21.12
Pygments               2.17.2
PyGObject              3.48.2
PyJWT                  2.7.0
pyparsing              3.1.1
pyrsistent             0.20.0
pyserial               3.5
python-apt             2.7.7+ubuntu3
pytz                   2024.1
PyYAML                 6.0.1
requests               2.31.0
rich                   13.7.1
setuptools             68.1.2
six                    1.16.0
systemd-python         235
ubuntu-drivers-common  0.0.0
unattended-upgrades    0.1
urllib3                2.0.7
wadllib                1.3.6
wheel                  0.42.0
xkit                   0.0.0

But isn't this more of a strategic question? I surmise like you that Debian really should have had this straightened out. Mysql-Connector is scarcely a niche library. It would seem that the Debian crowd has pulled a Crowdstrike and rushed this straight to production.

Isn't the real question that maybe I should just port this over to gentoo? I plan to ship this to clients in a virtual machine. Ideally said virtual machine would run on VMware, Virtualbox and Qemu.

Is Gentoo the wrong approach?

Thanks for your input. I really appreciate it.

A couple of things stand out.

First, mysql-connector-python is listed at 8.0.15 on both systems.
Looking on https://pypi.org/project/mysql-connector-python/#history that version was released beginning of 2019 (over 5 years ago!)
The latest release version is 9.0.0

Second, your old system has pyOpenSSL, but there isn't an obvious 'ssl' library on your new system. Maybe the underlying error is that there is no SSL library to use (which it fails to handle), then it complains about not being able to find what it was looking for.

TBH, I'd start with pip --upgrade to get everything up to date (but see below first).
I didn't check how crusty the rest of your modules were.

Do you know about Python virtual envs?
https://docs.python.org/3/library/venv.html
You can create mini environments tuned to your application, without having to worry about whether installing/removing particular packages will trash your whole machine.

Instead of shipping a VM, consider Docker
https://www.freecodecamp.org/news/docker-vs-vm-key-differences-you-should-know/

commented: Thanks again! Replied below! +0

@Salem

Thanks again, Salem!!

OK I ran pip install --upgrade as suggested and predictably pip complained that I should probably be using a python virtual environment. I'm going to spend some time reading up on this today.

...I'd like to request for comments on whether or not this is the right approach? I'd consider it to be the right approach if it will head off more of such bugs in the future, and if it will give me as a sys admin more granular control over my python execution environment. Which I would have to guess that it would. Your suggestion really seems to fit my design philopsohy.

Thanks again for your sage advice. I really appreciate it. I'm learning so much on this journey. Sorry to keep bugging you guys with this but if I can fix these design-level issues than so much of the rest of this will be smooth sailing.

commented: Thanks!!!!! +16
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.