ImportError: cannot import name 'NeuroPy'

154 Views Asked by At
from NeuroPy import NeuroPy

object1=NeuroPy("COM6") 

def attention_callback(attention_value):
    print ("Value of attention is",attention_value)
    return None

object1.setCallBack("attention",attention_callback)

object1.start()

while True:
    if(object1.meditation>70):
        object1.stop() 

I run this code and get this error:

$ python thread.py
Traceback (most recent call last):
  File "thread.py", line 1, in <module>
    from NeuroPy import NeuroPy
  File "D:\pu\fyp\neuro\NeuroPy.py", line 1, in <module>
    from NeuroPy import NeuroPy
ImportError: cannot import name 'NeuroPy'

I changed my file name to NeuroPy.py but it makes no difference. I also changed

from NeuroPy import NeuroPy

to

from NeuroPy.NeuroPy import NeuroPy

and

object1=NeuroPy("COM6")

to

object1=NeuroPy.NeuroPy("COM6")

but I still face some errors

from NeuroPy.NeuroPy import NeuroPy

ModuleNotFoundError: No module named 'NeuroPy.NeuroPy'; 'NeuroPy' is not a package
1

There are 1 best solutions below

0
BoarGules On

NeuroPy is not part of the Python standard library so you have to install it before you can import it.

The command for this is

pip install NeuroPy

And you should absolutely not name your program NeuroPy.py even after you have installed the module, and if you have a program of that name, delete or rename it. Otherwise, your program will shadow the module you are trying to import.