在Linux环境中,我希望能够将嵌入式python3设置为特定的python版本。我当前的monetDB安装似乎使用了3.7,尽管所有默认的python路径都指向3.8.6。
有没有办法将我的3.8.6安装设置为默认的嵌入式python3版本?
发布于 2020-12-04 04:42:06
经过一些试验之后,问题看起来是这样的:因为您是使用apt安装MonetDB的,所以安装会拉出发行版打包在apt中的python版本。我假设您是从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,如downloads page中所述。
然后,我在容器中创建了一个数据库场和一个新数据库,将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我从一个不同的发行版(Ubuntu Focal)开始重复上述过程,该发行版打包了不同版本的Python (似乎Ubuntu自从Focal发布以来已经更新到Python3.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 (有关说明,请参阅README ),要么从在其包管理器中打包Python3.8的发行版开始构建容器。
https://stackoverflow.com/questions/65079976
复制相似问题