---
title: 编译并安装自定义算子包时提示"AttributeError: module ‘onnxruntime’ has no attribute ‘SessionOption’"信息
description: "安装AMCT过程中，编译并安装自定义算子包时，出现\"AttributeError: module 'onnxruntime' has no attribute 'SessionOption' \"错误，编译过程中止，AMCT无法使用。"
url: https://www.hiascend.com/document/detail/zh/canncommercial/latest/devaids/amct/atlasamct_16_0358.html
sourcePath: /source/zh/canncommercial/900/devaids/amct/atlasamct_16_0358.html
indexId: a13fdc510c37f645d8f38666d0c54e7b78e02564b67932bb0c3c46071ef9084465
---
# 编译并安装自定义算子包时提示"AttributeError: module ‘onnxruntime’ has no attribute ‘SessionOption’"信息

#### 问题现象描述

安装AMCT过程中，编译并安装自定义算子包时，出现"AttributeError: module 'onnxruntime' has no attribute 'SessionOption' "错误，编译过程中止，AMCT无法使用。


#### 原因分析

Python环境中的ONNX Runtime库异常或者版本不满足要求，没有SessionOption属性。


#### 解决措施

1. 首先确认ONNX Runtime的版本是否为环境所要求的（详情请参见  系统要求和环境检查
），若不是，则请安装正确版本。
2. 在Python环境中import onnxruntime查看其版本（version）和路径（path），若仍旧提示AttributeError，则说明ONNX Runtime未正确安装，请参见如下命令强制重新安装ONNX Runtime。

```
pip3 install --force-reinstall onnxruntime==1.
x.x
--user
```


  造成ONNX Runtime未正确安装的原因可能是用户同时安装了onnxruntime和onnxruntime_gpu，卸载其中一个版本，导致另一个也无法正常使用。
