mindspore-ai / mindspore

MindSpore is a new open source deep learning training/inference framework that could be used for mobile, edge and cloud scenarios.
https://gitee.com/mindspore/mindspore
Apache License 2.0
4.16k stars 686 forks source link

import mindspore errors with ModuleNotFoundError #19

Open ligc opened 4 years ago

ligc commented 4 years ago

Environment

Hardware Environment(Ascend/GPU/CPU):

/device cpu

Software Environment:

Describe the current behavior

root@mindspore:~/mindspore# python3.7 --version
Python 3.7.5
root@mindspore:~/mindspore# python3.7 -c 'import mindspore'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/root/mindspore/mindspore/__init__.py", line 17, in <module>
    from . import common, train
  File "/root/mindspore/mindspore/common/__init__.py", line 16, in <module>
    from . import dtype
  File "/root/mindspore/mindspore/common/dtype.py", line 20, in <module>
    from .._c_expression import typing, EnvInstance_
ModuleNotFoundError: No module named 'mindspore._c_expression'
root@mindspore:~/mindspore#

Describe the expected behavior

Being able to import mindspore correctly.

Steps to reproduce the issue

  1. Build Python 3.7.5 manually
  2. Run command pip3.7 install https://ms-release.obs.cn-north-4.myhuaweicloud.com/0.1.0-alpha/MindSpore/cpu/ubuntu-x86/mindspore-0.1.0-cp37-cp37m-linux_x86_64.whl to install mindspore
  3. python3.7 -c 'import mindspore'

Related log / screenshot

Special notes for this issue

The procedure of building Python 3.7.5:

wget https://www.python.org/ftp/python/3.7.5/Python-3.7.5.tgz
tar zxvf Python-3.7.5.tar.gz
cd Python-3.7.5
./configure --enable-optimizations --prefix=/usr/local/python3.7 --enable-shared
make -j4
make install

cp /usr/local/python3.7/lib/libpython3.7m.so.1.0 /usr/lib/x86_64-linux-gnu/
cd /usr/bin
ln -s /usr/local/python3.7/bin/python3.7 python3.7
ln -s /usr/local/python3.7/bin/pip3.7 pip3.7
quarter-3 commented 4 years ago

May I ask if you have

  1. Set your PYTHONPATH to your source directoy, and
  2. If there is a file or directory named "mindspore" in current directory? Cheers.
kisnwangg commented 4 years ago

hi @ligc , the error occurred because python take your current mindspore source dir as mindspore module path, please cd out off mindspore dir and try again.