我在尝试导入sagemaker包时突然开始出现导入错误:
ImportError: dlopen(/opt/homebrew/Caskroom/miniforge/base/envs/imputation/lib/python3.10/site-packages/google/protobuf/pyext/_message.cpython-310-darwin.so, 0x0002): symbol not found in flat namespace '__ZN6google8protobuf15FieldDescriptor12TypeOnceInitEPKS1_'
查看错误来源使我认为是:
/opt/homebrew/Caskroom/miniforge/base/envs/imputation/lib/python3.10/site-packages/google/protobuf/descriptor.py:47
45 import binascii
46 import os
---> 47 from google.protobuf.pyext import _message
48 _USE_C_DESCRIPTORS = True
51 class Error(Exception):
我通常运行代码的其他部分,所以这个导入可能在几个月前就被破坏了。这部分代码没有经过测试,我也不经常运行它。我尝试删除我的python环境并重新安装Sagmaker,但仍然失败。这些是包裹。它有Python 3.10.8
appnope 0.1.3
asttokens 2.2.1
attrs 22.2.0
backcall 0.2.0
boto3 1.26.53
botocore 1.29.53
contextlib2 21.6.0
decorator 5.1.1
dill 0.3.6
executing 1.2.0
google-pasta 0.2.0
importlib-metadata 4.13.0
ipython 8.8.0
jedi 0.18.2
jmespath 1.0.1
matplotlib-inline 0.1.6
multiprocess 0.70.14
numpy 1.24.1
packaging 23.0
pandas 1.5.3
parso 0.8.3
pathos 0.3.0
pexpect 4.8.0
pickleshare 0.7.5
pip 22.3.1
pox 0.3.2
ppft 1.7.6.6
prompt-toolkit 3.0.36
protobuf 3.20.3
protobuf3-to-dict 0.1.5
ptyprocess 0.7.0
pure-eval 0.2.2
Pygments 2.14.0
python-dateutil 2.8.2
pytz 2022.7.1
s3transfer 0.6.0
sagemaker 2.129.0
schema 0.7.5
setuptools 66.0.0
six 1.16.0
smdebug-rulesconfig 1.0.1
stack-data 0.6.2
traitlets 5.8.1
urllib3 1.26.14
wcwidth 0.2.6
wheel 0.38.4
zipp 3.11.0
protobuf 3.20.3
可能是问题所在。看看这个:https://github.com/protocolbuffers/protobuf/issues/10571
这是protobuf版本。
pip install --upgrade protobuf==3.20.1
fixed it