MySQL Shell and extra Python modules

When you use MySQL Shell with extra Python plugins (like these available on GitHub), sometimes, you could need extra Python modules.

Some of my plugins require requests and prettytable for example.

MySQL 8.0.26 uses embedded Python 3.9 and if your system doesn’t have that version (like Oracle Linux 8), you won’t be able to install the missing module.

So how could we install the missing modules ? The easiest method is to use PIP, but if you don’t have PIP for Python 3.9 installed on the system, this will be more complicated…. not really !

This how to install PIP in MySQL Shell:

wget https://bootstrap.pypa.io/get-pip.py
mysqlsh --py -f get-pip.py 

And now you can use PIP to install extra modules:

mysqlsh --pym pip install --user prettytable 

When you know how to do it, it’s very easy.

Enjoy MySQL and MySQL Shell !

Subscribe to Blog via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

4 Comments

  1. Hi Moshin,

    first you create a directory where you will download the modules you need and you run the command as follow

    $ mkdir pip_download
    $ cd pip_download
    $ mysqlsh --pym pip download  prettytable
    

    Then you copy the directory and its content on the target host.
    Finally you install the module(s) like this:

    $ mysqlsh --pym pip install --nod-index --user --find-links pip_download/ prettytable
    

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

As MySQL Community Manager, I am an employee of Oracle and the views expressed on this blog are my own and do not necessarily reflect the views of Oracle.

You can find articles I wrote on Oracle’s blog.