当在本地目录上执行Python3(Python 3.6.8)脚本时,它可以正常工作,但在Slurm中运行sbatch作业时,会抱怨certifi。
在Python代码中添加以下内容:
或者这个:
在运行Python代码时(没有在Python代码中包含“import certifi”这一行),会出现错误:
错误(在Python代码中包含'import 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'
什么可能是这个问题的解决方案?
pygments
做同样的操作。看起来这是brew配方中的一个临时打包错误? - undefinedpygments
是下一个问题。我注意到python-certifi
也是ca-certificates
所需的。我尝试了一下,在安装了python-certifi
之后,我能够成功移除/安装httpie
,然后pygments
也作为依赖项被安装了。整个问题是在最近的Python 3更新之后开始的,我在想是不是有什么东西搞乱了python-certifi
或者homebrew,导致了对python-certifi
的依赖解析失败,然后这个问题就蔓延到了其他依赖项上? - undefined