Python 没有名为certifi的模块

Python 没有名为certifi的模块,python,cron,slurm,modulenotfounderror,certifi,Python,Cron,Slurm,Modulenotfounderror,Certifi,在本地目录上执行python3(python3.6.8)脚本时,它工作得很好,但在slurm中运行sbatch作业时,会抱怨certifi python3 -m pip install certifi Defaulting to user installation because normal site-packages is not writeable Requirement already satisfied: certifi in /usr/local/lib/python3.6/sit

在本地目录上执行python3(python3.6.8)脚本时,它工作得很好,但在slurm中运行sbatch作业时,会抱怨certifi

python3 -m pip install certifi

Defaulting to user installation because normal site-packages is not writeable
Requirement already satisfied: certifi in /usr/local/lib/python3.6/site-packages (2020.12.5)
在向python代码中添加以下内容后:

import sys
import os
sys.path.append(os.getcwd())
或者这个:

import sys
import os
module_path = os.path.abspath(os.getcwd())

if module_path not in sys.path:

    sys.path.append(module_path)
同样的错误也会发生。似乎安装了certifi

pip show certifi

Name: certifi
Version: 2020.12.5
Summary: Python package for providing Mozilla's CA Bundle.
Home-page: https://certifiio.readthedocs.io/en/latest/
Author: Kenneth Reitz
Author-email: me@kennethreitz.com
License: MPL-2.0
Location: /usr/local/lib/python3.6/site-packages
Requires:
Required-by: requests
运行python代码后出现错误(python代码中没有“import certifi”行):

回溯(最近一次呼叫最后一次):
文件“/home/username/test/test.py”,第19行,在
从textack.augmentation导入单词Netaugmenter、EmbeddedingAugmenter、EasyDataAugmenter、CharSwapAugmenter
文件“/home/username/.local/lib/python3.6/site packages/textack/\uuuuu init\uuuuuu.py”,第12行,在
从…起进口(
文件“/home/username/.local/lib/python3.6/site packages/textack/attack_recipes/_init__.py”,第21行,在
from.attack\u recipe导入AttackRecipe
文件“/home/username/.local/lib/python3.6/site packages/textack/attack_recipes/attack_recipe.py”,第9行,在
来自textattack.shared导入攻击
文件“/home/username/.local/lib/python3.6/site-packages/textack/shared/_-init__.py”,中第11行
from.import-utils
文件“/home/username/.local/lib/python3.6/site packages/textack/shared/utils/_init__.py”,第1行,在
从。安装导入*
文件“/home/username/.local/lib/python3.6/site packages/textack/shared/utils/install.py”,第9行,在
导入请求
文件“/home/username/.local/lib/python3.6/site packages/requests/_init__.py”,第118行,在
from.import-utils
文件“/home/username/.local/lib/python3.6/site packages/requests/utils.py”,第25行,在
从。导入证书
文件“/home/username/.local/lib/python3.6/site packages/requests/certs.py”,第15行,在
从哪里进口
ModuleNotFoundError:没有名为“certifi”的模块
错误(在python代码中具有“import certifi”行):

回溯(最近一次呼叫最后一次):
文件“/home/username/projecttest\u LR\u attack/LR\u attack.py”,第17行,在
进口证书
ModuleNotFoundError:没有名为“certifi”的模块

该问题的解决方案是什么?

这可能意味着
/usr/local/lib/python3.6/site packages/
不是slurm中sbatch作业可以访问的
PYTHONPATH
环境变量。您可以在运行时添加或追加它:

import sys
sys.path.append('/usr/local/lib/python3.6/site-packages/')

计算节点上安装的模块是否与本地安装的模块相同?您可能需要与Slurm管理员联系。

谢谢您的回答,PApostol。但错误仍然是一样的……谢谢。我得到的建议是创建一个包含所有所需安装的VM。
Traceback (most recent call last):
  File "/home/username/projecttest_LR_attack/LR_attack.py", line 17, in <module>
    import certifi
ModuleNotFoundError: No module named 'certifi'
import sys
sys.path.append('/usr/local/lib/python3.6/site-packages/')