python3.9 module 'pivy' has no attribute '__version__'

Having trouble installing or compiling FreeCAD? Get help here.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
FreddyFreddy
Posts: 176
Joined: Wed Mar 09, 2022 3:15 am
Location: Oz

python3.9 module 'pivy' has no attribute '__version__'

Post by FreddyFreddy »

Code: Select all

bernie@Bernies-iMac ~ % python
Python 3.9.12 (main, Mar 26 2022, 15:51:15) 
[Clang 13.1.6 (clang-1316.0.21.2)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import pivy
>>> print(pivy.__path__)
_NamespacePath(['/usr/local/lib/python3.9/site-packages/pivy'])
>>> print(pivy.__version__)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: module 'pivy' has no attribute '__version__'
>>> 
>>> 
>>> 
bernie@Bernies-iMac ~ % /usr/local/Cellar/python@3.10/3.10.5/bin/python3.10
Python 3.10.5 (main, Jun 23 2022, 17:15:25) [Clang 13.1.6 (clang-1316.0.21.2.5)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import pivy
>>> print(pivy.__path__)
['/usr/local/lib/python3.10/site-packages/pivy']
>>> print(pivy.__version__)
0.6.6
OK in python3.10. Is this expected behaviour??
User avatar
onekk
Veteran
Posts: 6146
Joined: Sat Jan 17, 2015 7:48 am
Contact:

Re: python3.9 module 'pivy' has no attribute '__version__'

Post by onekk »

as pivy is an external library, probably here is not the right place to ask, maybe at the gihutb page of pivy, but you have to see if there is another way to obtain the "pivy version".

There is not an unique way and "__version__" denote a "internal variable" that should not be used by external calls, using python conventions. Sadly Python will not "hide" internal variables, so it is somewhat a "bad practice" using them.

in my installation of 0.20 that is using the Appimage for Linux:

Code: Select all

OS: Artix Linux (openbox)
Word size of FreeCAD: 64-bit
Version: 0.20.29177 (Git) AppImage
Build type: Release
Branch: (HEAD detached at 0.20)
Hash: 68e337670e227889217652ddac593c93b5e8dc94
Python 3.9.13, Qt 5.12.9, Coin 4.0.0, Vtk 9.1.0, OCC 7.5.3
Locale: Italian/Italy (it_IT)
Installed mods: 
  * Curves 0.3.0
These are some output from FC Python Console:

Code: Select all

import pivy
>>> pivy.sys.api_version
1013
>>> pivy.sys.version
'3.9.13 | packaged by conda-forge | (main, May 27 2022, 17:07:55) \n[GCC 10.3.0]'
>>> pivy.sys.version_info
sys.version_info(major=3, minor=9, micro=13, releaselevel='final', serial=0)
>>> pivy.pivy_meta.__version__
'0.6.6'
>>> pivy.__version__
'0.6.6'
>>> 
But it may depends by your type of installation, you don't supply any information that permit to guess what type of installation of FC you have, so it could be or not a problem related to FC.

Regards

Carlo D.
GitHub page: https://github.com/onekk/freecad-doc.
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.

Blog: https://okkmkblog.wordpress.com/
FreddyFreddy
Posts: 176
Joined: Wed Mar 09, 2022 3:15 am
Location: Oz

Re: python3.9 module 'pivy' has no attribute '__version__'

Post by FreddyFreddy »

I ask in the context of build, so I think this is the right place.

FindCoin3D.cmake:

Code: Select all

 IF(NOT PIVY_VERSION)
    execute_process (COMMAND ${Python3_EXECUTABLE} -c "import pivy as p; print(p.__version__,end='')" OUTPUT_VARIABLE PIVY_VERSION)
  ENDIF()
__version__ is used in cmake summary display. When it fails, it is shown as blank.

I see in source this ability to show version was added some 4 years ago. It looks like I have picked up an older python, perhaps?
User avatar
waebbl
Posts: 200
Joined: Thu Aug 16, 2018 3:12 pm

Re: python3.9 module 'pivy' has no attribute '__version__'

Post by waebbl »

FreddyFreddy wrote: Sun Jul 24, 2022 12:06 am __version__ is used in cmake summary display. When it fails, it is shown as blank.
Not sure this is the reason for an empty summary display. On Gentoo, the pivy version in the summary has been empty for a long time


-- Coin3D: [/usr/lib64/libCoin.so] [/usr/include]
-- Pivy:
-- SPNAV: [/usr/lib64/libspnav.so] [/usr/include]


Yet


$ python
Python 3.10.5 (main, Jun 8 2022, 00:48:05) [GCC 11.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pivy
>>> print(pivy.__version__)
0.6.7
>>>
User avatar
onekk
Veteran
Posts: 6146
Joined: Sat Jan 17, 2015 7:48 am
Contact:

Re: python3.9 module 'pivy' has no attribute '__version__'

Post by onekk »

FreddyFreddy wrote: Sun Jul 24, 2022 12:06 am I ask in the context of build, so I think this is the right place.

FindCoin3D.cmake:

Code: Select all

 IF(NOT PIVY_VERSION)
    execute_process (COMMAND ${Python3_EXECUTABLE} -c "import pivy as p; print(p.__version__,end='')" OUTPUT_VARIABLE PIVY_VERSION)
  ENDIF()
__version__ is used in cmake summary display. When it fails, it is shown as blank.

I see in source this ability to show version was added some 4 years ago. It looks like I have picked up an older python, perhaps?
Maybe using pivy.pivy_meta.__version__ could be a solution if is present in old and new pivy implementation?

Regards

Carlo D.
GitHub page: https://github.com/onekk/freecad-doc.
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.

Blog: https://okkmkblog.wordpress.com/
FreddyFreddy
Posts: 176
Joined: Wed Mar 09, 2022 3:15 am
Location: Oz

Re: python3.9 module 'pivy' has no attribute '__version__'

Post by FreddyFreddy »

Maybe using pivy.pivy_meta.__version__ could be a solution if is present in old and new pivy implementation?
That is exactly what the pivy source does.
User avatar
onekk
Veteran
Posts: 6146
Joined: Sat Jan 17, 2015 7:48 am
Contact:

Re: python3.9 module 'pivy' has no attribute '__version__'

Post by onekk »

FreddyFreddy wrote: Sun Jul 24, 2022 9:47 am That is exactly what the pivy source does.
I have not inspected sources, but it could not be too hard to imagine that internally:

Code: Select all

__version__ = pivy_meta.__version__
or similar code is used in latest version of pivy

if it is not a big hassle to change the line in the CMAKE to retrieve the "original information" supplied from pivy_meta and not the mirrored on on pivy "main".

Probably it worth to signal it to the maintainer?

Regards

Carlo D.
GitHub page: https://github.com/onekk/freecad-doc.
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.

Blog: https://okkmkblog.wordpress.com/
FreddyFreddy
Posts: 176
Joined: Wed Mar 09, 2022 3:15 am
Location: Oz

Re: python3.9 module 'pivy' has no attribute '__version__'

Post by FreddyFreddy »

onekk wrote: Sun Jul 24, 2022 9:53 am if it is not a big hassle to change the line in the CMAKE to retrieve the "original information" supplied from pivy_meta and not the mirrored on on pivy "main"
Except that pivy_meta likely does not exist in this version!
User avatar
onekk
Veteran
Posts: 6146
Joined: Sat Jan 17, 2015 7:48 am
Contact:

Re: python3.9 module 'pivy' has no attribute '__version__'

Post by onekk »

@wmayer What do you think?
GitHub page: https://github.com/onekk/freecad-doc.
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.

Blog: https://okkmkblog.wordpress.com/
wmayer
Founder
Posts: 20243
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: python3.9 module 'pivy' has no attribute '__version__'

Post by wmayer »

FreddyFreddy wrote: Sat Jul 23, 2022 4:23 am OK in python3.10. Is this expected behaviour??
At least this issue is independent on FreeCAD and likely a bug in pivy. Are the two pivy versions for Py3.9 and Py3.10 built from the exact same sources?
Post Reply