本地运行Watson Machine Learning时遇ImportError问题求助
Windows本地VSCode虚拟环境对接Watson Machine Learning遇ImportError问题
问题描述
在Windows本地VSCode的虚拟环境中运行Jupyter Notebook,尝试对接Watson Machine Learning时失败。已执行以下安装命令:
!pip install tensorflow !pip install ibm_watson_machine_learning
已在Notebook中成功创建并训练Keras模型,确认tensorflow可正常运行,但执行初始化Watson ML客户端代码时:
from ibm_watson_machine_learning import APIClient LOCATION = 'https://us-south.ml.cloud.ibm.com' API_KEY = 'xxx-this-is-my-api-key-xxx' wml_credentials = { "apikey": API_KEY, "url": LOCATION } wml_client = APIClient(wml_credentials)
触发如下错误:
ImportError: The system lacks installations of pyspark, scikit-learn, pandas, xgboost, mlpipelinepy, ibmsparkpipeline and tensorflow. At least one of the libraries is required for the repository-client to be used
解决方法
重新升级tensorflow
尽管已安装tensorflow,但可能存在版本兼容或虚拟环境识别问题,执行升级命令确保库在当前环境中正常加载:!pip install --upgrade tensorflow安装任意指定依赖库
错误提示要求至少安装列表中的一个库,若升级tensorflow无效,可选择安装常用的pandas或scikit-learn:# 安装pandas !pip install pandas # 或安装scikit-learn !pip install scikit-learn重启Notebook内核
依赖库安装完成后,重启Jupyter Notebook的内核,再重新运行初始化APIClient的代码即可。
内容的提问来源于stack exchange,提问作者Maximilian Jesch
相关产品推荐
相关产品推荐

