赞
踩
運行代碼報錯:
Traceback (most recent call last):
File “/opt/module/python_shell/huaweicloud/service.py”, line 2, in
import util
File “/opt/module/python_shell/huaweicloud/util.py”, line 1, in
from huaweicloudsdkcore.auth.credentials import GlobalCredentials
ModuleNotFoundError: No module named ‘huaweicloudsdkcore’
按照往常的思路,直接pip安裝
(superset) [xxx@hadoop102 huaweicloud]$ pip install huaweicloudsdkcore
Requirement already satisfied: huaweicloudsdkcore in /opt/module/miniconda3/envs/superset/lib/python3.9/site-packages (3.1.91)
Requirement already satisfied: requests-toolbelt>=0.10.1 in /opt/module/miniconda3/envs/superset/lib/python3.9/site-packages (from huaweicloudsdkcore) (1.0.0)
Requirement already satisfied: six>=1.16.0 in /opt/module/miniconda3/envs/superset/lib/python3.9/site-packages (from huaweicloudsdkcore) (1.16.0)
Requirement already satisfied: simplejson>=3.18.0 in /opt/module/miniconda3/envs/superset/lib/python3.9/site-packages (from huaweicloudsdkcore) (3.19.1)
Requirement already satisfied: PyYAML>=5.4.1 in /opt/module/miniconda3/envs/superset/lib/python3.9/site-packages (from huaweicloudsdkcore) (6.0)
Requirement already satisfied: pyasn1>=0.5.0 in /opt/module/miniconda3/envs/superset/lib/python3.9/site-packages (from huaweicloudsdkcore) (0.6.0)
Requirement already satisfied: typing-extensions in /opt/module/miniconda3/envs/superset/lib/python3.9/site-packages (from huaweicloudsdkcore) (4.10.0)
Requirement already satisfied: requests<3.0.0,>=2.0.1 in /opt/module/miniconda3/envs/superset/lib/python3.9/site-packages (from requests-toolbelt>=0.10.1->huaweicloudsdkcore) (2.31.0)
Requirement already satisfied: charset-normalizer<4,>=2 in /opt/module/miniconda3/envs/superset/lib/python3.9/site-packages (from requests<3.0.0,>=2.0.1->requests-toolbelt>=0.10.1->huaweicloudsdkcore) (3.1.0)
Requirement already satisfied: idna<4,>=2.5 in /opt/module/miniconda3/envs/superset/lib/python3.9/site-packages (from requests<3.0.0,>=2.0.1->requests-toolbelt>=0.10.1->huaweicloudsdkcore) (3.4)
Requirement already satisfied: urllib3<3,>=1.21.1 in /opt/module/miniconda3/envs/superset/lib/python3.9/site-packages (from requests<3.0.0,>=2.0.1->requests-toolbelt>=0.10.1->huaweicloudsdkcore) (1.26.15)
Requirement already satisfied: certifi>=2017.4.17 in /opt/module/miniconda3/envs/superset/lib/python3.9/site-packages (from requests<3.0.0,>=2.0.1->requests-toolbelt>=0.10.1->huaweicloudsdkcore) (2022.12.7)
發現也安裝成功了,沒有報錯,再執行,還是報錯:
Traceback (most recent call last):
File "/opt/module/python_shell/huaweicloud/service.py", line 2, in <module>
import util
File "/opt/module/python_shell/huaweicloud/util.py", line 1, in <module>
from huaweicloudsdkcore.auth.credentials import GlobalCredentials
ModuleNotFoundError: No module named 'huaweicloudsdkcore'
代碼在本地是可以跑成功的,問了gpt,可能是python版本不同導致的
找到了本地安裝華為雲的記錄
(env) PS C:\Users\xxx\PycharmProjects\pythonProject> pip install huaweicloudsdkcore
Requirement already satisfied: huaweicloudsdkcore in c:\users\sarah.x\documents\env\lib\site-packages (3.1.90)
Requirement already satisfied: requests-toolbelt>=0.10.1 in c:\users\sarah.x\documents\env\lib\site-packages (from huaweicloudsdkcore) (1.0.0)
Requirement already satisfied: six>=1.16.0 in c:\users\sarah.x\documents\env\lib\site-packages (from huaweicloudsdkcore) (1.16.0)
Requirement already satisfied: simplejson>=3.18.0 in c:\users\sarah.x\documents\env\lib\site-packages (from huaweicloudsdkcore) (3.19.2)
Requirement already satisfied: PyYAML>=5.4.1 in c:\users\sarah.x\documents\env\lib\site-packages (from huaweicloudsdkcore) (6.0.1)
Requirement already satisfied: pyasn1>=0.5.0 in c:\users\sarah.x\documents\env\lib\site-packages (from huaweicloudsdkcore) (0.6.0)
Requirement already satisfied: typing-extensions in c:\users\sarah.x\documents\env\lib\site-packages (from huaweicloudsdkcore) (4.9.0)
Requirement already satisfied: requests<3.0.0,>=2.0.1 in c:\users\sarah.x\documents\env\lib\site-packages (from requests-toolbelt>=0.10.1->huaweicloudsdkcore) (2.31.0)
Requirement already satisfied: charset-normalizer<4,>=2 in c:\users\sarah.x\documents\env\lib\site-packages (from requests<3.0.0,>=2.0.1->requests-toolbelt>=0.10.1->huaweicloudsdkcore) (3.3.2)
Requirement already satisfied: idna<4,>=2.5 in c:\users\sarah.x\documents\env\lib\site-packages (from requests<3.0.0,>=2.0.1->requests-toolbelt>=0.10.1->huaweicloudsdkcore) (3.6)
Requirement already satisfied: urllib3<3,>=1.21.1 in c:\users\sarah.x\documents\env\lib\site-packages (from requests<3.0.0,>=2.0.1->requests-toolbelt>=0.10.1->huaweicloudsdkcore) (2.1.0)
Requirement already satisfied: certifi>=2017.4.17 in c:\users\sarah.x\documents\env\lib\site-packages (from requests<3.0.0,>=2.0.1->requests-toolbelt>=0.10.1->huaweicloudsdkcore) (2023.11.17)
(env) PS C:\Users\SARAH.X\PycharmProjects\pythonProject> python
Python 3.12.1 (tags/v3.12.1:2305ca5, Dec 7 2023, 22:03:25) [MSC v.1937 64 bit (AMD64)] on win32
Type “help”, “copyright”, “credits” or “license” for more information.
發現華為雲安裝的版本還真不一樣,所以使用conda安裝了python12
conda create --name pythonThirteen python=3.12
安裝成功
Downloading and Extracting Packages
Preparing transaction: done
Verifying transaction: done
Executing transaction: done
#
# To activate this environment, use
#
# $ conda activate pythonThirteen
#
# To deactivate an active environment, use
#
# $ conda deactivate
後面執行命令成功跑完
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。