ModuleNotFoundError: No module named 'pyhamilton'

I have a couple issues w.r.t. the installation.

running pyhamilton-new-project after having changed directories obviously does not work since the files relating to the new project are in the directory above. Not really an issue since I just move the files manually.

However, when running py robot_method.py I get the following error:

from pyhamilton import (HamiltonInterface,  LayoutManager,
ModuleNotFoundError: No module named 'pyhamilton'

What is the issue here? Obviously there is no module, but my question is why? It’s not present in the new directory nor in the original installation/configuration directory. The pyhamilton-configure and pyhamilton-new-method commands execute without any issues.

Any help would be greatly appreciated :slight_smile:

Hi, thanks for the question.

running pyhamilton-new-project after having changed directories obviously does not work since the files relating to the new project are in the directory above. Not really an issue since I just move the files manually.

I’m a little confused by this. The files are copied into whatever folder you are inside of in the command line. Changing directories before you run the command just means that the files will copy into your new working directory. There could be something wrong with how the script executes, but the expected behavior is to be able to run py robot_method.py immediately after pyhamilton-new-project regardless of whichever directory you happen to be in. mkdir + cd are just used so you don’t clutter up a parent directory.

What is the issue here? Obviously there is no module, but my question is why? It’s not present in the new directory nor in the original installation/configuration directory. The pyhamilton-configure and pyhamilton-new-method commands execute without any issues.

It seems that you must have run pip install pyhamilton, because you have the command-line functions working. That means that pyhamilton installed somewhere that is not in your sys.path variable. Here’s what we can do: figure out where pyhamilton was installed, cross-reference this against your sys.path variable to double-check our hypothesis that the former is not in the latter, and then add the former path to your PYTHONPATH environment variable.

Please let me know if you need help finding out where pip installed pyhamilton to, or with any other steps in these instructions!

Hi Stefan

Just wanted to drop in and say thanks a lot for your reply! I did some playing around today and have managed to get everything working. Not entirely sure what it was but I suspect that it had something to do with conda, as once I uninstalled conda I managed to get things working.

Regarding your Getting Started guide, under step nine you write:

  • Run. If you have other Python versions installed, always run pyhamilton with py yourmethod.py (the bundled Python launcher, which interprets shebangs) or python3 yourmethod.pyPress accept to proceed with the bundled installers."

However, when I run at that stage of the process I get no installers popping up. Should I be seeing installers here? For me it merely seems to run a simple protocol (the one created in step 8) in Venus which I suspect is the “test method” that you have built to test the installation.

Having moved on from the above, I got started on the next part of your guide, " Your First PyHamilton Method". I’m still tinkering but I am getting a bit of an issue with the script that you write. It seems the procedure should be tip_pickup>aspirate>dispense>tip_eject, but when I run the exact same script it just collects one set of tips, then nothing (a bunch of stuff being written to trace) before the method terminates. Not sure what the issue is but I will tackle that tomorrow. Just a couple questions in the meantime

  • Should all sequences be user-defined (i.e. not system-controlled)? I could only get my “First PyHamilton Method” to do anything when I abandoned the tips as system-controlled and instead defined them as their own sequence (tips_1 etc).
  • Could deck layout/instrument type be a problem? I see your example methods are running on what appears to be a Starlett, whereas I am using a Star.

Anyway, thanks again for your help, and apologies for the inexperience!

1 Like

Hi,

I found what the problem was in the code I provided. This error will have popped up in your command-line application: Traceback (most recent call last): File "C:\Users\stefa\forum-test\robot_method.py", line 24, in <module> aspirate(ham_int, aspiration_poss, vols_list, liquidClass = liq_class) NameError: name 'vols_list' is not defined

I recommend running the same code to verify this same error on your end. To fix it, do this: add the line vols_list = [100]*8 anywhere in the code before you reference the vols_list variable. I’ve fixed it in the Getting Started guide.

In general, if something went wrong there will be an error code in the command-line output.