Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

expected LockingPolicy #60

Closed
Lycos2 opened this issue Jun 24, 2018 · 9 comments
Closed

expected LockingPolicy #60

Lycos2 opened this issue Jun 24, 2018 · 9 comments

Comments

@Lycos2
Copy link

Lycos2 commented Jun 24, 2018

hello,
I'm a biginner in programming, i'm working on a project with myo to use it with people with Parkinson disease, a month earlier I used the myo master SDK to assure the connection and it worked but now the same script won't work (I didn't change anything) can you help me please to solve this issue :
runfile('C:/Users/ELYES/Desktop/myo_test/myo-python-master/01_hello_myo.py', wdir='C:/Users/ELYES/Desktop/myo_test/myo-python-master')
[autoreload of sitecustomize failed:

Traceback (most recent call last):
  File "C:\Users\ELYES\Anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 705, in runfile
    else:
  File "C:\Users\ELYES\Anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 102, in execfile
    with open(filename, 'rb') as f:
  File "C:/Users/ELYES/Desktop/myo_test/myo-python-master/01_hello_myo.py", line 48, in <module>
    hub = myo.Hub()
  File "C:\Users\ELYES\Desktop\myo_test\myo-python-master\myo\_ffi.py", line 468, in __init__
    self.locking_policy = LockingPolicy.none
  File "C:\Users\ELYES\Desktop\myo_test\myo-python-master\myo\_ffi.py", line 491, in locking_policy
    raise TypeError('expected LockingPolicy')
TypeError: expected LockingPolicy
@NiklasRosenstein
Copy link
Owner

NiklasRosenstein commented Jun 24, 2018

Hi Lycos2,

I can not reproduce it here. Could you help me debug this please?

In the _ffi.py file, please modify the Hub.locking_policy setter function starting at line 488 so that it reads

  @locking_policy.setter
  def locking_policy(self, policy):
    print('@@@', repr(policy), type(policy), type(policy).__module__, LockingPolicy.__module__, type(policy) is LockingPolicy)
    if not isinstance(policy, LockingPolicy):
      raise TypeError('expected LockingPolicy')
    error = ErrorDetails()
    libmyo.libmyo_set_locking_policy(self._handle[0], int(policy), error.handle)
    error.raise_for_kind()

After that, run your Python script again and please paste the output in the console.

Please put any terminal output in code blocks like so:

```
Code here
```

@Lycos2
Copy link
Author

Lycos2 commented Jun 24, 2018

Hi Niklas,
thx for helping me, i did what you told me and this is the output:

runfile('C:/Users/ELYES/Desktop/myo_test/myo-python-master/01_hello_myo.py', wdir='C:/Users/ELYES/Desktop/myo_test/myo-python-master')
Traceback (most recent call last):

  File "<ipython-input-1-8c68dda46196>", line 1, in <module>
    runfile('C:/Users/ELYES/Desktop/myo_test/myo-python-master/01_hello_myo.py', wdir='C:/Users/ELYES/Desktop/myo_test/myo-python-master')

  File "C:\Users\ELYES\Anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 706, in runfile
    execfile(filename, namespace)

  File "C:\Users\ELYES\Anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 103, in execfile
    exec(compile(f.read(), filename, 'exec'), namespace)

  File "C:/Users/ELYES/Desktop/myo_test/myo-python-master/01_hello_myo.py", line 48, in <module>
    hub = myo.Hub()

  File "C:\Users\ELYES\Desktop\myo_test\myo-python-master\myo\_ffi.py", line 469, in __init__
    self.locking_policy = LockingPolicy.none

  File "C:\Users\ELYES\Desktop\myo_test\myo-python-master\myo\_ffi.py", line 490, in locking_policy
    print('@@@', repr(policy), type(policy), type(policy.__module__), LockingPolicy.__module__, type(policy) is LockingPolicy)

AttributeError: 'int' object has no attribute '__module__'

@NiklasRosenstein
Copy link
Owner

Hm that is weird. Something seems to be wrong with the enumeration types. Can you tell me the exact version of Python you are using and the version of the nr library that is installed?

python --version
python -c "import nr; print(nr.__version__)"

@Lycos2
Copy link
Author

Lycos2 commented Jun 24, 2018

(base) C:\Users\ELYES>python --version
Python 3.6.5 :: Anaconda, Inc.

(base) C:\Users\ELYES>python -c "import nr; print(nr.version)"
1.3.5

@NiklasRosenstein
Copy link
Owner

How did you install myo-python?

We require nr>=2.0.10 which should have been upgraded automatically when you installed it via Pip. 😕

pip install 'nr>=2.0.10'

should fix your problem.

@Lycos2
Copy link
Author

Lycos2 commented Jun 24, 2018

hi Niklas,
I updated nr to 'nr>=2.0.12' and i got that :
"""""
runfile('C:/Users/ELYES/Anaconda3/my_project/myo-python-master (1)/myo-python-master/01_hello_myo.py', wdir='C:/Users/ELYES/Anaconda3/my_project/myo-python-master (1)/myo-python-master')
Traceback (most recent call last):

File "", line 1, in
runfile('C:/Users/ELYES/Anaconda3/my_project/myo-python-master (1)/myo-python-master/01_hello_myo.py', wdir='C:/Users/ELYES/Anaconda3/my_project/myo-python-master (1)/myo-python-master')

File "C:\Users\ELYES\Anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 706, in runfile
execfile(filename, namespace)

File "C:\Users\ELYES\Anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 103, in execfile
exec(compile(f.read(), filename, 'exec'), namespace)

File "C:/Users/ELYES/Anaconda3/my_project/myo-python-master (1)/myo-python-master/01_hello_myo.py", line 28, in
import myo

File "C:\Users\ELYES\Anaconda3\my_project\myo-python-master (1)\myo-python-master\myo_init_.py", line 26, in
from ._ffi import *

File "C:\Users\ELYES\Anaconda3\my_project\myo-python-master (1)\myo-python-master\myo_ffi.py", line 72, in
class Result(nr.enum.Enumeration):

AttributeError: module 'nr' has no attribute 'enum'
""""""

@NiklasRosenstein
Copy link
Owner

Uhm and what happens if you type import nr.enum in your Python interpreter?

@Lycos2
Copy link
Author

Lycos2 commented Jun 24, 2018

I did that and it seems ok!!
""""""

(base) C:\Users\ELYES>python
Python 3.6.5 |Anaconda, Inc.| (default, Mar 29 2018, 13:32:41) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.

import nr.enum

"""""

@NiklasRosenstein
Copy link
Owner

Could you come over to https://gitter.im/NiklasRosenstein/myo-python? I have some more questions regarding your environment.

@Lycos2 Lycos2 closed this as completed Jul 1, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants