Dear Community,
I am using containers in nextflow, without having any problems, the only prblem is, when i want to run python scripts (from the python installed inside the container), it can not imports all installed python libraries.
Command error:
/opt/conda/envs/drop/bin/python
Python 3.10.14
Traceback (most recent call last):
File "/mainfs/genepy.py", line 1, in <module>
from numba import njit, cuda, prange
ModuleNotFoundError: No module named 'numba'
but i checked it, seems python version and path is exactly that i need .
/opt/conda/envs/drop/bin/python
Python 3.10.14
running apptainer outside the Next flow, i can run python inside the container and load all libraries, but in next flow it doesnt work.
#!/opt/conda/envs/drop/bin python
from numba import njit, cuda, prange
import numpy as np
import pandas as pd
import math
import pyarrow.csv as pa_csv
from typing import Tuple
import argparse
import time
import os
import sys
ok , i found the error,
the problem is, when i was making a docker image , numba library installed in the /opt/.local/sitepackage/python path instead of /opt/conda/env.
adding this line to the python code , solved the problem
import sys
sys.path.append(“/drop/.local/lib/python3.10/site-packages”
but my question is , how come running it outside the nextflow everything is fine , but when it runs inside the nextflow, it doesnt work? it should not behave the same?
If you’re using the nf-core pipeline template, you might find that nextflow.config is setting an environment variable PYTHONNOUSERSITE = 1 which we added for exactly this reason - to prevent the user’s Python libraries getting into the container run time.
Otherwise it could be down to what directories are mounted (including the home directory).