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

[Python 3] AttributeError: 'function' object has no attribute 'im_func' #124

Open
nim65s opened this issue May 6, 2019 · 26 comments
Open

Comments

@nim65s
Copy link
Member

nim65s commented May 6, 2019

Hi,

While trying to test #123 on 16.04 / python 3, with an omniORB 4.2.2 build for python 3, I got the following error:

  File "robots.py", line 23, in main
    robot.initDisplay()
  File "…/lib/python3.5/site-packages/pinocchio/robot_wrapper.py", line 281, in initDisplay
    import gepetto.corbaserver
  File "…/lib/python3.5/site-packages/gepetto/__init__.py", line 18, in <module>
    from .color import Color
  File "…/lib/python3.5/site-packages/gepetto/color.py", line 20, in <module>
    from .corbaserver import Color
  File "…/lib/python3.5/site-packages/gepetto/corbaserver/__init__.py", line 1, in <module>
    from .gepetto.corbaserver import GraphicalInterface
  File "…/lib/python3.5/site-packages/gepetto/corbaserver/gepetto/__init__.py", line 9, in <module>
    import gepetto.corbaserver.graphical_interface_idl
  File "…/lib/python3.5/site-packages/gepetto/corbaserver/graphical_interface_idl.py", line 700, in <module>
    _0_gepetto.corbaserver._objref_GraphicalInterface.createWindow.im_func.__doc__ = _0_gepetto.corbaserver.GraphicalInterface.createWindow__doc__
AttributeError: 'function' object has no attribute 'im_func'

This can be fixed with sed -i 's/im_func.__doc__/__doc__/' graphical_interface_idl.py

@nim65s
Copy link
Member Author

nim65s commented May 6, 2019

https://docs.python.org/2/reference/datamodel.html says:

doc is the method’s documentation (same as im_func.doc);

(but we don't care about Python 2 here, anyway)

and https://docs.python.org/3/library/2to3.html?highlight=im_func#2to3fixer-methodattrs
seems to say that this has been removed.

I'll update #123

@jmirabel
Copy link
Contributor

jmirabel commented May 6, 2019

I think I had this working not so long ago. Are you sure that Gepetto-viewer did not get confused (i.e. it really uses omniidl from your build) ?

@nim65s
Copy link
Member Author

nim65s commented May 6, 2019

I can find im_func in omniorbpy-4.2.2/python3, so it looks like the bug comes from there, and not from GV / GVC. Maybe it was introduced in 4.2.

@jmirabel
Copy link
Contributor

jmirabel commented May 6, 2019

I checked on the workspace I used. I did not generate the doc, so obviously, it worked.

@nim65s
Copy link
Member Author

nim65s commented May 6, 2019

4.2.3 is available, I'll try to update

@nim65s
Copy link
Member Author

nim65s commented May 6, 2019

Yes, #123 works, but this is a separate issue

@jmirabel
Copy link
Contributor

jmirabel commented May 6, 2019

Do you mean that the documentation generation (and execution) works with Python 3 and OmniORB 4.2.3 ?

@nim65s
Copy link
Member Author

nim65s commented May 6, 2019

No change between 4.2.2 & 4.2.3.

With the sed, I can get this:

In [7]: robot.viewer.gui.createWindow??
Signature: robot.viewer.gui.createWindow(*args)
Docstring:
Create a new window.
\param input name : name of the new window.
return the ID of the newly create window.

Prototype:          unsigned long createWindow(in string name) raises (Error);
Source:   
    def createWindow(self, *args):
        return self._obj.invoke("createWindow", _0_gepetto.corbaserver.GraphicalInterface._d_createWindow, args)
File:      /local/gsaurel/robotpkg/install/lib/python3.5/site-packages/gepetto/corbaserver/graphical_interface_idl.py
Type:      method

So I think that documentation generation (and execution) almost works with Python 3 and OmniORB 4.2.2

@jmirabel
Copy link
Contributor

jmirabel commented May 6, 2019

I am fine with using sed as long as it is well commented in CMakeLists.txt.

@nim65s
Copy link
Member Author

nim65s commented May 6, 2019

I tried nim65s/jrl-cmakemodules@5294b95 without success, but with https://github.com/nim65s/robotpkg/blob/0730604/middleware/omniORBpy/patches/patch-af it works, so we could do with it.
I'll open an issue on omniORB.

@jmirabel
Copy link
Contributor

jmirabel commented May 6, 2019

It's weird nim65s/jrl-cmakemodules@5294b95 didn't work.

We will have issues later on distribution where OmniORB 4.2.3 is already supported. We can postpone the problem and hope that you change will be accepted by OmniORB devs.

@jviereck
Copy link

jviereck commented Mar 17, 2020

Is there any progress on this one? When installing gepetto-gui via gepetto/homebrew-gepetto 1 it installs OmniORB 4.2.3 and I run into this problem.

My current workaround is to do the substitution as proposed in the first comment.

@jmirabel
Copy link
Contributor

As far as I understand, there is a mix between Python 2 and Python 3.

If you have the documentation, it means you use Python 3, don't you ?
What matters is your version of omniidl. I suspect you have omniidl 4.2.2 and not omniidl 4.2.3.

@jmirabel
Copy link
Contributor

And you need omniidl (and omniidl-python) 4.2.3 to have Python 3 working properly.

@jviereck
Copy link

I've installed all omni related things through the gepetto/homebrew-gepetto formular omniorbpy.rb 1, which installs omniorb in version 4.2.3. It seems to install something for python 2.7 as well.

If that helps, here is the output

$ omniidl -V
omniidl version 1.0

@jmirabel
Copy link
Contributor

dpkg -l *omniidl* ?

@nim65s
Copy link
Member Author

nim65s commented Mar 17, 2020

dpkg means Debian PacKaGe, so I think this is not used by homebrew.

And this patch is still in robotpkg, to remove this im_func in omniorbpy 4.2.3

I reported that here: https://www.omniorb-support.com/pipermail/omniorb-list/2019-May/032063.html and got an answer from the maintainer there: https://www.omniorb-support.com/pipermail/omniorb-list/2019-June/032067.html :

The fix is in svn, in the 4_2 branch.

But I am not aware of any new released version on this 4_2 branch.

@jviereck: I think you should either use a patched version as we do on robotpkg, or download a devel version on the svn upstream repository. I guess @jcarpent is the maintainer of gepetto/homebrew-gepetto, so he'll probably have answers for this. I have no skills on OSX yet ^^

@jviereck
Copy link

Thanks @jmirabel @nim65s - I patched the file manually for now and it seems to work.

@jcarpent
Copy link
Member

@jviereck I've just patched it on brew and conda. Things should work fine now.

@jcarpent
Copy link
Member

I've pushed the fix to https://github.com/Gepetto/omniORBpy. Might be useful for other projects

@jmirabel
Copy link
Contributor

Thank you @jcarpent. @jviereck I let you close this if it worked.

@jviereck
Copy link

When reinstalling things for python3.8 I ran into this problem:

/usr/local/lib/python3.8/site-packages/gepetto/corbaserver/graphical_interface_idl.py in <module>
    751 #
    752
--> 753 omniORB.setDocString(_0_gepetto.corbaserver._objref_NodeCallback.selected, _0_gepetto.corbaserver.NodeCallback.selected__doc__)
    754 omniORB.setDocString(_0_gepetto.corbaserver._objref_GraphicalInterface.createWindow, _0_gepetto.corbaserver.GraphicalInterface.createWindow__doc__)
    755 omniORB.setDocString(_0_gepetto.corbaserver._objref_GraphicalInterface.getWindowID, _0_gepetto.corbaserver.GraphicalInterface.getWindowID__doc__)

AttributeError: module 'omniORB' has no attribute 'setDocString'

The previous problem with 'function' object has no attribute 'im_func' didn't show up anymore.

@nim65s
Copy link
Member Author

nim65s commented Apr 29, 2020

I can't reproduce on python 3.8 on Arch. Which version of omniORB do you have ?

@jviereck
Copy link

omniorb is at version 4.2.4 for me.

If you cannot reproduce I guess we can close this bug.

@meisbokai
Copy link

Hello, sorry for commenting here even though it has been 4 years, but since the issue hasn't been closed, I'll just write my question here.

Currently I'm on Ubuntu 20, with Python 3.8.

I have installed omniidl and omniidl-python

dpkg -l *omniidl*

Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name           Version         Architecture Description
+++-==============-===============-============-======================================================
ii  omniidl        4.2.2-0.9build4 amd64        omniORB IDL to C++ and Python compiler
ii  omniidl-python 4.2.2-0.2build4 all          omniidl backend to compile Python stubs from IDL files

I've also built omniORB and omniORBpy from source, and I'm able to import them

Python 3.8.20 (default, Sep 17 2024, 02:58:30) 
[GCC 9.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import omniORB
>>> omniORB.__version__
'4.3.2'
>>> 

However, when I attempt to import gepetto, I will receive the error regarding a missing im_func

Python 3.8.20 (default, Sep 17 2024, 02:58:30) 
[GCC 9.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import gepetto
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.8/site-packages/gepetto/__init__.py", line 18, in <module>
    from .color import Color  # noqa: F401
  File "/usr/local/lib/python3.8/site-packages/gepetto/color.py", line 20, in <module>
    from .corbaserver import Color  # noqa: F401
  File "/usr/local/lib/python3.8/site-packages/gepetto/corbaserver/__init__.py", line 2, in <module>
    from .gepetto import Error  # noqa: F401
  File "/usr/local/lib/python3.8/site-packages/gepetto/corbaserver/gepetto/__init__.py", line 9, in <module>
    import gepetto.corbaserver.graphical_interface_idl
  File "/usr/local/lib/python3.8/site-packages/gepetto/corbaserver/graphical_interface_idl.py", line 780, in <module>
    _0_gepetto.corbaserver._objref_NodeCallback.selected.im_func.__doc__ = _0_gepetto.corbaserver.NodeCallback.selected__doc__
AttributeError: 'function' object has no attribute 'im_func'
>>> 

Is this due to the difference in versions between omniidl (4.2.2) and omniOrb (4.3.2)?

@florent-lamiraux
Copy link
Contributor

Why don't you use binary packages instead of building from source ?
gepetto-viewer-corba is provided by robotpkg. See here: http://robotpkg.openrobots.org/debian.html.

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

No branches or pull requests

6 participants