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

initialization: graphics_toolkit: 2004h toolkit is not available #237

Open
pirofti opened this issue Apr 18, 2022 · 5 comments
Open

initialization: graphics_toolkit: 2004h toolkit is not available #237

pirofti opened this issue Apr 18, 2022 · 5 comments
Labels

Comments

@pirofti
Copy link

pirofti commented Apr 18, 2022

Hi,

I just updated oct2py and Octave on my system and I get the following error in python and jupyter whenever I try to execute an oct2py command.

$ python -i
Python 3.10.4 (main, Mar 23 2022, 23:05:40) [GCC 11.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import oct2py
>>> oc = oct2py.Oct2Py()
>>> x = oc.zeros(3,3)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3.10/site-packages/oct2py/core.py", line 758, in __getattr__
    exist = self._exist(name)
  File "/usr/lib/python3.10/site-packages/oct2py/core.py", line 709, in _exist
    exist = int(resp.split()[-1])
ValueError: invalid literal for int() with base 10: '\x1b[?2004h'

Here is the output from jupyter:

Screenshot from 2022-04-18 12-01-39

The problem is, I think the communication between oct2py and Octave.

$ ipython
Python 3.10.4 (main, Mar 23 2022, 23:05:40) [GCC 11.2.0]
Type 'copyright', 'credits' or 'license' for more information
IPython 8.2.0 -- An enhanced Interactive Python. Type '?' for help.

In [1]: import oct2py

In [2]: oc = oct2py.Oct2Py()

In [3]: x = oc.zeros(3,3)
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
Input In [3], in <cell line: 1>()
----> 1 x = oc.zeros(3,3)

File /usr/lib/python3.10/site-packages/oct2py/core.py:758, in Oct2Py.__getattr__(self, attr)
    755     raise Oct2PyError('Session is closed')
    757 # Make sure the name exists.
--> 758 exist = self._exist(name)
    760 if exist not in [2, 3, 5, 103]:
    761     msg = 'Name "%s" is not a valid callable, use `pull` for variables'

File /usr/lib/python3.10/site-packages/oct2py/core.py:709, in Oct2Py._exist(self, name)
    707 cmd = 'exist("%s")' % name
    708 resp = self._engine.eval(cmd, silent=True).strip()
--> 709 exist = int(resp.split()[-1])
    710 if exist == 0:
    711     cmd = 'class(%s)' % name

ValueError: invalid literal for int() with base 10: '\x1b[?2004h'

In [4]: debug
> /usr/lib/python3.10/site-packages/oct2py/core.py(709)_exist()
    707         cmd = 'exist("%s")' % name
    708         resp = self._engine.eval(cmd, silent=True).strip()
--> 709         exist = int(resp.split()[-1])
    710         if exist == 0:
    711             cmd = 'class(%s)' % name

ipdb> name
'zeros'
ipdb> resp
'\x1b[?2004l\rans = 5\r\n\x1b[?2004h'

I get this with any other method that might be the first to run after oct2py is initialized (e.g. available_graphics_toolkits, ones). The faulty string never changes, it always has the same value. These commands run just fine in Octave, so I think it is a communication issue.

Any tips of what I might try next?

Thank you,
Paul

@blink1073
Copy link
Owner

Hi @pirofti, what OS and what version of Octave are you using? It looks like we need to add handling for those control characters. This issue looks relevant: pexpect/pexpect#669

@pirofti
Copy link
Author

pirofti commented Apr 18, 2022

@blink1073, I am using ArchLinux 5.17.3-arch1-1 and Octave 7.1.0. Both updated today.

@pirofti
Copy link
Author

pirofti commented Apr 18, 2022

Hi @pirofti, what OS and what version of Octave are you using? It looks like we need to add handling for those control characters. This issue looks relevant: pexpect/pexpect#669

This workaround from the issue you mentioned, indeed, fixes the issue for me.

@blink1073
Copy link
Owner

Great, thanks for verifying. I think that might be the best we can do, based on this response.

@pirofti
Copy link
Author

pirofti commented Apr 18, 2022

Right. I don't know what this new feature is supposed to do, but disabling it everywhere seems wrong also. Anyway, you decide which way to go, but it should probably be in the documentation as well so that us users can find it quickly.

Thank you for looking into this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants