我正在尝试在 IBM Cloud 部署的函数中使用 spaCy 模型,但 spacy 的安装失败且没有特定错误。
如何重现:
def dummy_deployable_function():
try:
import subprocess
subprocess.check_output("pip install spacy --user", stderr=subprocess.STDOUT, shell=True)
except subprocess.CalledProcessError as e:
install_err = "subprocess.CalledProcessError:\n\n" + "cmd:\n" + e.cmd + "\n\noutput:\n" + e.output.decode()
raise Exception( "Installing failed:\n" + install_err )
import spacy
def score(payload):
return payload["values"][0]
return score
from watson_machine_learning_client import WatsonMachineLearningAPIClient
wml_credentials = { # not shown :-)
"apikey": "",
"instance_id": "",
"password": "",
"url": "",
"username": ""
}
client = WatsonMachineLearningAPIClient( wml_credentials )
# Store the function
meta_data = { client.repository.FunctionMetaNames.NAME : 'Dummy Model' }
function_details = client.repository.store_function( meta_props=meta_data, function=dummy_deployable_function )
function_id = function_details["metadata"]["guid"]
function_deployment_details = client.deployments.create( artifact_uid=function_id, name='Dummy Model Deployment')
我收到的“错误”的最后一行只是:
安装收集的包:srsly、attrs、pyrsistent、jsonschema、wasabi、cymem、preshed、murmurhash、plac、blis、thinc、spacy
pip的退出码是-9。
关于如何解决这个问题的任何想法(或替代解决方案)?可以安装许多其他软件包(包括所有 spacy 依赖项)。谢谢你的帮助。