MySQLdb for 3.6 on RHEL7
On 14/08/19 6:14 AM, Chris Angelico wrote:
> On Wed, Aug 14, 2019 at 1:48 AM Larry Martell <larry.martell at gmail.com> wrote:
>> On Tue, Aug 13, 2019 at 9:59 AM Chris Angelico <rosuav at gmail.com> wrote:
>>> On Tue, Aug 13, 2019 at 11:33 PM Larry Martell <larry.martell at gmail.com> wrote:
>>>> I am trying to install MySQLdb (https://pypi.org/project/mysqlclient/)
>>>> for python3.6 on RHEL7.
>>>> When I import it, it fails:
>>>> Has anyone seen and resolved this?
>>> Not specifically, but that looks like a versioning conflict. Most
>>> likely, your mysqlclient is too old for MySQLdb to connect to.
>>> Did you get one of them from your system package manager and the other
>>> from pip? If so, try to get both from the same place.
>> So I have MySQL from the system package manager, but mysqlclient is
>> not available there.
By which you mean RedHat's repository?
> That seems very odd. The mysqlclient binary might be just under a
> different name? I'm not familiar with RHEL, but on my Debian, there
> are packages like "mysql-server-5.7" and corresponding
> "mysql-client-5.7". Or do you mean the Python client?
Just in case: please be aware that the MySQL-client which enables a
cmdLN interface to the server, is quite different from the
Python-Connector which will be called from Python code.
>> And I was not able to get that from pip either,
>> as the install failed. I had to download the source, edit the site.cfg
>> file and build it. But I just found python36-mysql.x86_64 as a package
>> so I uninstalled mysqlclient and installed that from the repo.
> Based on this, I'm thinking possibly you meant the Python client. It
> may still be that you need to install the C client for the Python one
> to connect to. Although.... if you got python36-mysql from your system
> repo, that ought to drag in the appropriate mysqlclient. So now I'm
> very confused.
>> That did not get the above error, but now I get this:
>> raise ImproperlyConfigured('mysqlclient 1.3.13 or newer is
>> required; you have %s.' % Database.__version__)
>> django.core.exceptions.ImproperlyConfigured: mysqlclient 1.3.13 or
>> newer is required; you have 1.3.12.
> This claims to be a Django error, though, so maybe the issue here
> isn't with MySQLdb but with Django?? Maybe everything up above is
> actually correctly matched, but too old?
I often develop on CentOS/Fedora* whereas the client has paid-for RedHat
support. To keep the two environments in-sync, I always use the MySQL
* which is yet another 'battle' because "MariaDB" may be installed
by-default, in preference to MySQL)
As Chris has said, there are combinations of clients and servers, many
of which are incompatible. Like him, I've stuck with MySQL v5 by reason
of exactly this sort of inter-dependence (MySQL-Workbench? - admittedly
a decision made, I estimate, over one year ago) - whereas MySQL
Community will 'favor' v8.n!
- clear-out 'everything' MySQL-related
- install the MySQL (Community) site's repo (v5 or v8, as you see fit)
- using rpm/yum/dnf, assemble your tool-set directly from them
- test using the MySQL cmdLN client
- only thereafter move to testing the Python/Django connection.
I have no problems with/complaints about MySQL's Python-Connector (and
usually stick to the simpler interface/API).
Various alternative interfaces (to MySQL's) seem quite similar, and
often require identical code/function calls from within Python...
I can't speak to the Django-MySQL interface.
When the time comes, your client can shell-out for MySQL support, and
build (essentially) the same environment for the 'live env', from those