a-hurst / klibs

A simple Python framework for writing cognitive psychology experiments
7 stars 1 forks source link

Windows klibs running error -- NameError: name 'cli' is not defined #5

Closed mmcsweeney closed 2 years ago

mmcsweeney commented 3 years ago

Hello, I am trying to run a klibs experiment from a laptop running on Windows 10. I receive the following error with something called 'cli'. (Also note--if I try to run it without python -m as a prefix, the klibs command is not recognized.)

C:\Users\user\Desktop\TMTM_tremorStudy>python -m klibs run 15.0 Traceback (most recent call last): File "C:\Program Files (x86)\PsychoPy2_PY3\lib\runpy.py", line 193, in _run_module_as_main "main", mod_spec) File "C:\Program Files (x86)\PsychoPy2_PY3\lib\runpy.py", line 85, in _run_code exec(code, run_globals) File "C:\Program Files (x86)\PsychoPy2_PY3\lib\site-packages\klibs__main__.py", line 24, in cli() NameError: name 'cli' is not defined

a-hurst commented 3 years ago

Hey @mmcsweeney, it looks like you're trying to run your klibs project with a PsychoPy-installed version of Python. Can you try installing the latest 64-bit Python 3.8 from Python.org (make sure to check 'Add Python to PATH' during installation) and then try running

python -m pip install https://github.com/a-hurst/klibs/releases/latest/download/klibs.tar.gz

To install the latest version?

Also, this is very exciting: this is the first time I've seen someone from outside my own lab(s) using klibs in the wild! Can I ask where you heard of the package?

mmcsweeney commented 3 years ago

Hi @a-hurst, thanks for your response! My supervisor knows some researchers at Dalhousie and we've been corresponding with one of these researchers about administering an attentional blink task to our study participants that was programmed using klibs.

I followed your advice and no longer get the 'cli' error.

However, we are now trying to figure out another obstacle-- when I am in the project directory and enter 'klibs run 15', I get an error message that says: " Error: the project name in 'experiment.py' (Project_name) does not match the names of any of the project's configuration files. Please verify the project structure and try again. "

The same exact project files work seamlessly on Mac, so I am wondering if there are different project naming conventions in Mac vs. Windows in klibs? Have you encountered this problem before?

a-hurst commented 3 years ago

@mmcsweeney Hmm, I think that might be my fault: I introduced a bug where projects don't load properly if they have underscores in their name, and I've fixed it locally but haven't pushed those changes to GitHub yet (I've changed a bunch of other things which might break stuff in other projects).

I've pushed my testing branch with the fix for you to try, you can install it using:

pip install git+https://github.com/a-hurst/klibs.git@spring_updates_2021

Let me know if that fixes it, and/or if you run into any more issues!

mmcsweeney commented 3 years ago

Thanks! I installed the new fix and still encountered the same error, but I renamed my project without the underscore and it seems to work now.

a-hurst commented 3 years ago

@mmcsweeney Are you sure the new version installed correctly? If you add the line from klibs.KLUserInterface import get_clicks to the top of the project's experiment.py and it still runs, it installed right which means I didn't fix the original issue. If it tells you that function doesn't exist, you may need to prefix the install command with pythom -m and or add a -U flag in front of pip install (to force an update).