在Linux环境中,我希望能够将嵌入式python3设置为特定的python版本。3.7
即使所有默认的python路径都指向,我当前的monetDB安装似乎仍在使用3.8.6
。
有没有办法将我的3.8.6
安装设置为默认的嵌入式python3版本?
经过一些试验后,问题似乎出在以下方面:因为您正在使用安装MonetDB apt
,所以安装会提取发行版本打包在其中的python版本apt
。我认为您是从开始构建容器的python:3.8
。这基于打包Python 3.7的Debian Buster。
更详细一点:
我使用以下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
与文件monetdb.list
,并MonetDB-GPG-KEY
按照所描述的下载页面。
然后,我在容器中创建了一个数据库场和一个新数据库,设置embedpy3
为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
使用mclient
我创建了一个Python UDF,它以字符串形式返回嵌入式python解释器的版本:
CREATE FUNCTION pyversion ()
RETURNS STRING
LANGUAGE python {
import sys
return sys.version
};
当我调用它时,得到以下结果:
sql>select pyversion();
+-----------------------------------------------------+
| %2 |
+=====================================================+
| 3.7.3 (default, Jul 25 2020, 13:03:44) |
: [GCC 8.3.0] :
+-----------------------------------------------------+
1 tuple
我从打包不同版本Python的另一个发行版(Ubuntu Focal)开始重复了上述过程(自从Focal发行以来,Ubuntu已更新到Python 3.8.5)。
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
在此容器中,函数pyversion
返回以下内容:
sql>select pyversion();
+-----------------------------------------------------+
| %2 |
+=====================================================+
| 3.8.5 (default, Jul 28 2020, 12:59:40) |
: [GCC 9.3.0] :
+-----------------------------------------------------+
1 tuple
总之,我建议要么从容器中的源代码构建MonetDB(请参阅自述文件以获取指示信息),要么从在其软件包管理器中打包Python 3.8的发行版开始构建容器。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句