如何在singularity容器中安装python包?

2024-05-15 05:24:09 发布

您现在位置:Python中文网/ 问答频道 /正文

我正试图在我的singularity容器上安装带有pip的软件包,但是如果不从我的机器上“借用”这些软件包,似乎就不可能做到这一点。我听说我可能需要使用virtualenv,但这似乎是一个迂回的过程。有人知道在他们的奇点容器上使用pip包的一种行之有效的方法吗


Tags: pip方法机器virtualenv过程容器singularity奇点
2条回答

你是如何建造你的容器的?您应该能够在容器中使用pip,就像在实际机器上安装一样

以下是一个例子:

Bootstrap: docker
From: python:3.7-alpine

%post 
    pip install click 

将其另存为文件,如test.def,然后构建容器:

sudo singularity build test.sif test.def

{a1}文件将有所帮助

一个好的解决方法是使用conda安装所需的软件包

BootStrap: docker
From: ubuntu:xenial

%environment
export PATH=/miniconda3/bin:$PATH

%runscript
exec vcontact "$@"

%post
apt-get update && apt-get install -y automake build-essential bzip2 wget git default-jre unzip

# Install miniconda 
wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh
bash Miniconda3-latest-Linux-x86_64.sh -b -f -p /miniconda3/
rm Miniconda3-latest-Linux-x86_64.sh

# pull the conda functions in . /miniconda3/etc/profile.d/conda.sh and make pip, etc. available while in %post
export PATH="/miniconda3/bin:$PATH"

# Use conda to install pip, numpy
conda install -y -c conda-forge pip numpy 

# Help conda resolving Python "import" 
conda update  all

相关问题 更多 >

    热门问题