Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Supported by

[solved] OpenSesame with Pygaze has a circular import in Mac.

rrrrrr
edited January 2016 in OpenSesame

Hello,

I have some suggestion about using OpenSeasame with Pygaze in MacOS.
Probably, I found some critical problem.

When using OpenSesame in Mac, it seems that Pygaze is imported from '/usr/local/lib/python2.7/site-packages/' even if the path of python is made to other directories.
So, there is no error (e.g., OSError: [Errno 2] No such file or directory: 'resources/fonts') after copying Pygaze into it.

Almost problem can be solved, but it may still has a different bug as below .

Traceback:
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/OpenSesame-release-3.0.2/libopensesame/inline_script.py", line 102, in run
    self.experiment.python_workspace._exec(self.crun)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/OpenSesame-release-3.0.2/libopensesame/python_workspace.py", line 160, in _exec
    exec(bytecode, self._globals)
  File "<string>", line 6, in <module>
  File "/usr/local/lib/python2.7/site-packages/pygaze/__init__.py", line 22, in <module>
    from pygaze.settings import settings
  File "/usr/local/lib/python2.7/site-packages/pygaze/settings.py", line 59, in <module>
    settings = Settings()
  File "/usr/local/lib/python2.7/site-packages/pygaze/settings.py", line 27, in __init__
    from pygaze import defaults
ImportError: cannot import name defaults

It shows that Pygaze includes a circular import.

Comments

  • edited November 2015

    Hi,

    I'm not familiar with your Python environment, but as a general tip: Python just takes the first matching thing from the Python path. In your case, this is apparently pygaze from site-packages. If you want to use a different pygaze, you can either remove the one from site-packages, or adjust the PYTHON_PATH. There's a neat (hidden) trick in OpenSesame to do this. If you create a file called environment.yaml (in the working direction of OpenSesame) you can specify where OpenSesame looks for Python modules and plugins. (The custom Python path will be prepended, so it will take precedence over the existing Python path.)

    PYTHON_PATH: /my/path/to/pygaze
    OPENSESAME_PLUGIN_PATH: /my/path/to/plugins
    OPENSESAME_EXTENSION_PATH: /my/path/to/extensions
    

    It shows that Pygaze includes a circular import.

    Where do you see a circular import?

    Just as a disclaimer: You are in pretty rough territory here: PyGaze 0.6.0 is under active development, and neither Edwin nor me uses Mac OS. But it's great that you're using it, because it will help us catch bugs. But

    Cheers,
    Sebastiaan

  • rrrrrr
    edited 12:08PM

    Hello,

    Thank you for your reply, and sorry for my many questions.

    I am trying to make a 'environment.yaml'.
    Which the 'plugins' should I use? Where should I put 'opensesame_plugins'?
    There are several plugins folder; plugins in Pygaze and in OpenSesame.

    Best,

  • edited 12:08PM

    The plugins that are bundled with PyGaze (in the folder opensesame_plugins) need to be somewhere OpenSesame can find them. To do so, you can add that folder (the full path to opensesame_plugins to the OPENSESAME_PLUGIN_PATH). Something like:

    OPENSESAME_PLUGIN_PATH: /my/path/to/pygaze/opensesame_plugins
    

    Does that make sense?

  • rrrrrr
    edited 12:08PM

    Hello sebastiaan,

    I added the path to OPENSESAME_PLUGIN_PATH, but I was not able to open Pygaze eye-tracking template in OpenSeasame because the error occurred when I tried to open it.

    File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/OpenSesame-release-3.0.2/libqtopensesame/qtopensesame.py", line 677, in open_file
        experiment_path=os.path.dirname(path))
      File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/OpenSesame-release-3.0.2/libqtopensesame/items/experiment.py", line 80, in __init__
        fullscreen=None)
      File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/OpenSesame-release-3.0.2/libopensesame/experiment.py", line 168, in __init__
        item.item.__init__(self, name, self, string)
      File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/OpenSesame-release-3.0.2/libopensesame/item.py", line 68, in __init__
        self.from_string(string)
      File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/OpenSesame-release-3.0.2/libopensesame/experiment.py", line 325, in from_string
        self.items.new(item_type, item_name, def_str)
      File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/OpenSesame-release-3.0.2/libqtopensesame/misc/qtitem_store.py", line 83, in new
        item = super(qtitem_store, self).new(_type, name=name, script=script)
      File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/OpenSesame-release-3.0.2/libopensesame/item_store.py", line 176, in new
        fromlist=[u'dummy'])
    ImportError: No module named pygaze_drift_correct
    

    I already changed the codes of 'pygaze_init.py'; from dummy to Eyelink.

    Should I change any other setting?

    Best

  • rrrrrr
    edited 12:08PM

    Hello sebastiaan,

    I succeeded to use OpenSeasame with Pygaze in MacOS!
    I needed to move the plugins ('pygaze_init', 'pygaze_log'...) to '/opensesame/plugins'.
    It doesn't work when I moved it to other plugins directories.

    Next, I try to use Pygaze in Expyriment script.
    How can I do that?
    Is it possible to add pygaze functions to my script of Expyriment, and copy it in the 'inline_script'?

    Best,

  • rrrrrr
    edited 12:08PM

    Hello,

    I was able to do the eye tracking!
    Pygaze functions (e.g., eyetracker....()) on 'inline_script' worked fine.

    Thank you very much for your kind advice.
    I hope this helps for all user of MacOS.

    Best,

  • edited 12:08PM

    Good to hear!

Sign In or Register to comment.