我正在尝试制作一个使用 python 脚本的 Nextflow 脚本。我的 python 脚本导入了许多模块,但在 Nextflow python3 中没有找到 7 个模块中的两个(cv2 和 matplotlib)并崩溃。如果我直接从 bash 调用脚本,它工作正常。我想避免创建一个 docker 镜像来运行这个脚本。
Error executing process > 'grab_images (1)'
Caused by:
Process `grab_images (1)` terminated with an error exit status (1)
Command executed:
python3 --version
echo 'processing image-1.npy'
python3 /home/hq/cv_proj/k_means2.py image-1.npy
Command exit status:
1
Command output:
Python 3.7.3
processing image-1.npy
Command error:
Traceback (most recent call last):
File "/home/hq/cv_proj/k_means2.py", line 5, in <module>
import matplotlib.pyplot as plt
ModuleNotFoundError: No module named 'matplotlib'
Work dir:
/home/hq/cv_proj/work/7f/b787c62ec420b2b5eb490603ef913f
Tip: you can replicate the issue by changing to the process work dir and entering the command `bash .command.run`
我认为存在路径问题,因为 numpy、sys、re、time 等模块已成功加载。我该如何解决?
提前致谢
更新
为了帮助其他可能在 nextflow 脚本中使用 python 遇到问题的人......确保你的 shebang 是正确的。我正在使用
#!/usr/bin/python
代替
#!/usr/bin/python3
由于我所有的软件包都安装了 pip3 并且我专门使用 python3 你需要有正确的 shebang。