0

In a Linux environment, I'd like to be able to set the embedded python3 to a specific python version. My current monetDB install seems to use 3.7 even though all default python paths point to 3.8.6.

Is there a way to set my 3.8.6 install as the default embedded python3 version?

  • Could you please let us know which version of monetdb you have, and how you installed it? – Panagiotis Koutsourakis Nov 30 '20 at 20:22
  • Running inside a linux-based docker container, installed using the latest version found at https://dev.monetdb.org/downloads/deb/ along with the following apt packages monetdb5-sql monetdb-client monetdb-python3 – Parker Johnson Nov 30 '20 at 23:31
  • Sorry for the late answer. I am not very familiar with docker unfortunately. Is it possible that inside the container there is a python `3.7` installed? I will play around with this kind of scenario tomorrow and get back to you. – Panagiotis Koutsourakis Dec 02 '20 at 15:18
  • I was looking more closely through my docker build and found that python3-dev was installing python 3.7. I will try to remove it and see if that resolves the issue. It is odd that monetDB wants that specific version though, as I am using a 3.8 container with 3.8 as default on everything. Appreciate you looking into this. – Parker Johnson Dec 02 '20 at 16:50

1 Answers1

0

After some experimentation, the problem seems to be the following: because you are installing MonetDB using apt, the installation pulls the python version that the distribution has packaged in apt. I assume that you are building your container starting from python:3.8. This is based on Debian Buster that packages Python 3.7.

In a bit more detail:

I built a container using the following Dockerfile:

FROM python:3.8

RUN apt-get update
RUN apt-get upgrade -y

COPY ./monetdb.list /etc/apt/sources.list.d/
COPY ./MonetDB-GPG-KEY /
RUN apt-key add /MonetDB-GPG-KEY
RUN apt-get update
RUN apt-get install -y monetdb5-sql monetdb-client monetdb-python3

with the files monetdb.list and MonetDB-GPG-KEY as described in the downloads page.

I then created a database farm and a new database in the container, setting embedpy3 to true:

root@bd0420e945e8:/# monetdbd create /tmp/dbfarm
root@bd0420e945e8:/# monetdbd start /tmp/dbfarm
root@bd0420e945e8:/# monetdb create -p monetdb pytestdb
created database with password for monetdb user: pytestdb
root@bd0420e945e8:/# monetdb set embedpy3=yes pytestdb

Using mclient I created a Python UDF that returns as a string the version of the embedded python interpreter:

CREATE FUNCTION pyversion () 
RETURNS STRING 
LANGUAGE python {
  import sys 
  return sys.version
};

When I called it I got the following result:

sql>select pyversion();
+-----------------------------------------------------+
| %2                                                  |
+=====================================================+
| 3.7.3 (default, Jul 25 2020, 13:03:44)              |
: [GCC 8.3.0]                                         :
+-----------------------------------------------------+
1 tuple

I repeated the above process starting from a different distribution (Ubuntu Focal) that packages a different version of Python (It seems that Ubuntu has updated to Python 3.8.5 since the release of Focal).

FROM ubuntu:20.04

RUN apt-get update
RUN apt-get upgrade -y
RUN apt-get install -y gnupg ca-certificates

COPY ./monetdb.list /etc/apt/sources.list.d/
COPY ./MonetDB-GPG-KEY /
RUN apt-key add /MonetDB-GPG-KEY
RUN apt-get update
RUN apt-get install -y monetdb5-sql monetdb-client monetdb-python3

In this container the function pyversion returns the following:

sql>select pyversion();
+-----------------------------------------------------+
| %2                                                  |
+=====================================================+
| 3.8.5 (default, Jul 28 2020, 12:59:40)              |
: [GCC 9.3.0]                                         :
+-----------------------------------------------------+
1 tuple

In conclusion, I would suggest to either build MonetDB from source in the container (see the README for instructions), or build your container starting from a distribution that packages Python 3.8 in its package manager.