没有名为 certifi 的模块
No module named certifi
在本地目录上执行 python3 (Python 3.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'行):
Traceback (most recent call last):
File "/home/username/test/test.py", line 19, in <module>
from textattack.augmentation import WordNetAugmenter, EmbeddingAugmenter, EasyDataAugmenter, CharSwapAugmenter
File "/home/username/.local/lib/python3.6/site-packages/textattack/__init__.py", line 12, in <module>
from . import (
File "/home/username/.local/lib/python3.6/site-packages/textattack/attack_recipes/__init__.py", line 21, in <module>
from .attack_recipe import AttackRecipe
File "/home/username/.local/lib/python3.6/site-packages/textattack/attack_recipes/attack_recipe.py", line 9, in <module>
from textattack.shared import Attack
File "/home/username/.local/lib/python3.6/site-packages/textattack/shared/__init__.py", line 11, in <module>
from . import utils
File "/home/username/.local/lib/python3.6/site-packages/textattack/shared/utils/__init__.py", line 1, in <module>
from .install import *
File "/home/username/.local/lib/python3.6/site-packages/textattack/shared/utils/install.py", line 9, in <module>
import requests
File "/home/username/.local/lib/python3.6/site-packages/requests/__init__.py", line 118, in <module>
from . import utils
File "/home/username/.local/lib/python3.6/site-packages/requests/utils.py", line 25, in <module>
from . import certs
File "/home/username/.local/lib/python3.6/site-packages/requests/certs.py", line 15, in <module>
from certifi import where
ModuleNotFoundError: No module named 'certifi'
错误(在 python 代码中有行 'import certifi'):
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'
问题的解决方案是什么?
这可能意味着 /usr/local/lib/python3.6/site-packages/
不是 slurm 中的 sbatch 作业可以访问的 PYTHONPATH
环境变量。您可以在运行时添加或附加它:
import sys
sys.path.append('/usr/local/lib/python3.6/site-packages/')
计算节点上是否安装了与本地相同的模块?您可能需要咨询 Slurm 管理员。
在本地目录上执行 python3 (Python 3.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'行):
Traceback (most recent call last):
File "/home/username/test/test.py", line 19, in <module>
from textattack.augmentation import WordNetAugmenter, EmbeddingAugmenter, EasyDataAugmenter, CharSwapAugmenter
File "/home/username/.local/lib/python3.6/site-packages/textattack/__init__.py", line 12, in <module>
from . import (
File "/home/username/.local/lib/python3.6/site-packages/textattack/attack_recipes/__init__.py", line 21, in <module>
from .attack_recipe import AttackRecipe
File "/home/username/.local/lib/python3.6/site-packages/textattack/attack_recipes/attack_recipe.py", line 9, in <module>
from textattack.shared import Attack
File "/home/username/.local/lib/python3.6/site-packages/textattack/shared/__init__.py", line 11, in <module>
from . import utils
File "/home/username/.local/lib/python3.6/site-packages/textattack/shared/utils/__init__.py", line 1, in <module>
from .install import *
File "/home/username/.local/lib/python3.6/site-packages/textattack/shared/utils/install.py", line 9, in <module>
import requests
File "/home/username/.local/lib/python3.6/site-packages/requests/__init__.py", line 118, in <module>
from . import utils
File "/home/username/.local/lib/python3.6/site-packages/requests/utils.py", line 25, in <module>
from . import certs
File "/home/username/.local/lib/python3.6/site-packages/requests/certs.py", line 15, in <module>
from certifi import where
ModuleNotFoundError: No module named 'certifi'
错误(在 python 代码中有行 'import certifi'):
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'
问题的解决方案是什么?
这可能意味着 /usr/local/lib/python3.6/site-packages/
不是 slurm 中的 sbatch 作业可以访问的 PYTHONPATH
环境变量。您可以在运行时添加或附加它:
import sys
sys.path.append('/usr/local/lib/python3.6/site-packages/')
计算节点上是否安装了与本地相同的模块?您可能需要咨询 Slurm 管理员。