# 报错：mindspore.\_c\_expression.typing.TensorType object is not callable

**1. 系统环境**

硬件环境\(Ascend/GPU/CPU\): Ascend/GPU/CPU

软件环境: MindSpore 版本: 1.8.1

执行模式（静态图/动态图）： 不限

Python 版本: 3.9.13

操作系统平台: linux

**2. 报错信息**

2.1 问题描述

创建Tensor时报错。

2.2 报错信息

```
Traceback (most recent call last):
File "D:\test.py", line 3, in
t1 = mindspore.tensor([1,2,3])
TypeError: 'mindspore._c_expression.typing.TensorType' object is not callable
```

2.3 脚本信息

```
import mindspore
t1 = mindspore.tensor([1,2,3])
print(t1)
```

**3. 根因分析**

代码中Tensor错误的写成了小写tensor，应该为Tensor

mindspore源码里面\_\_init\_\_.py。

```
from .common import *
```

common\\\_\_init\_\_.py

```
from . import dtype
```

common\\dtype.py

```
tensor = typing.TensorType()
```

TensorType定义如下：

```
class TensorType(Type):
    # no doc
    def element_type(self): # real signature unknown; restored from __doc__
        """ element_type(self: mindspore._c_expression.typing.TensorType) -> mindspore._c_expression.typing.Type """
        pass

    def __getstate__(self): # real signature unknown; restored from __doc__
        """ __getstate__(self: mindspore._c_expression.typing.TensorType) -> tuple """
        return ()

    def __init__(self, *args, **kwargs): # real signature unknown; restored from __doc__
        """
        __init__(*args, **kwargs)
        Overloaded function.

        1. __init__(self: mindspore._c_expression.typing.TensorType) -> None

        2. __init__(self: mindspore._c_expression.typing.TensorType, element: mindspore._c_expression.typing.Type) -> None
        """
        pass

    def __setstate__(self, arg0): # real signature unknown; restored from __doc__
        """ __setstate__(self: mindspore._c_expression.typing.TensorType, arg0: tuple) -> None """
        pass
```

父类定义如下：

```
class Type(__pybind11_builtins.pybind11_object):
    # no doc
    def __deepcopy__(self, arg0): # real signature unknown; restored from __doc__
        """ __deepcopy__(self: mindspore._c_expression.typing.Type, arg0: dict) -> mindspore._c_expression.typing.Type """
        pass

    def __eq__(self, arg0): # real signature unknown; restored from __doc__
        """ __eq__(self: mindspore._c_expression.typing.Type, arg0: object) -> bool """
        return False

    def __hash__(self): # real signature unknown; restored from __doc__
        """ __hash__(self: mindspore._c_expression.typing.Type) -> int """
        return 0

    def __init__(self, *args, **kwargs): # real signature unknown
        pass

    def __repr__(self): # real signature unknown; restored from __doc__
        """ __repr__(self: mindspore._c_expression.typing.Type) -> str """
        return ""

    def __str__(self): # real signature unknown; restored from __doc__
        """ __str__(self: mindspore._c_expression.typing.Type) -> str """
        return ""
```

typing.TensorType\(\)\(\[1,2,3\]\) 这种方式是无法调用的，所以会报错。

common\\\_\_init\_\_.py

```
from .tensor import Tensor, RowTensor, SparseTensor, COOTensor, CSRTensor
```

mindspore.Tensor 最终调用的是common\\tensor.py里面的Tensor类

**4. 解决方案**

修改mindspore.tensor 为mindspore.Tensor

```
import mindspore
t1 = mindspore.Tensor([1,2,3])
print(t1)
```

