LumaPictures / usd-qt

Reusable Qt Components for Pixar's USD
Other
153 stars 41 forks source link

cannot import name PrimFilterCache #34

Closed suesauer closed 4 years ago

suesauer commented 4 years ago

Hi there,

Been trying to build the outliner as part as our adoption of USD but I'm having a bit of a problem with the hierarchyModel.py script in Maya. And am at a loss at what to do. My setup Linux centos 7 Maya 2019.1 usd-qt: dev branch (was running into the same issue as https://github.com/LumaPictures/usd-qt/issues/22 but fixed that by going to the dev branch) USD: Master branch USD_Maya: refactoring_sandbox branch

Error I'm getting:

Error: ImportError: file ~/Documents/USD/lib/python/pxr/UsdQt/hierarchyModel.py line 30: cannot import name PrimFilterCache

Is there a known fix for this that I'm unaware of perhaps?

Thanks Sue

nrusch commented 4 years ago

Hi @suesauer,

I saw your thread on usd-interest, although this looks like a slightly different issue now. Can you provide the following information to start:

suesauer commented 4 years ago

Hi there @nrusch,

Here goes: ['/usr/autodesk/maya2019/bin', '/opt/pixar/RenderManForMaya-23.0/scripts', '/opt/pixar/RenderManProServer-23.0/bin', '/opt/pixar/RenderManProServer-23.0/lib/python2.7/site-packages', '/home/suesauer', '/home/suesauer/Documents/USD/lib/python', '/home/suesauer/Documents/WorkspaceRefractor/install/RelWithDebInfo/plugin/al/scripts', '/usr/autodesk/bifrost/maya2019/1.5.7.85/bifrost/scripts', '/usr/autodesk/maya/plug-ins/MASH/scripts', '/home/suesauer/Documents/WorkspaceRefractor/install/RelWithDebInfo/lib/scripts', '/home/suesauer/Documents/WorkspaceRefractor/install/RelWithDebInfo/plugin/adsk/scripts', '/home/suesauer/Documents/WorkspaceRefractor/install/RelWithDebInfo/scripts', '/home/suesauer/Documents/WorkspaceRefractor/install/RelWithDebInfo/plugin/pxr/scripts', '/home/suesauer/Documents/USD/scripts', '/usr/autodesk/maya/plug-ins/fbx/scripts', '/opt/hfs18.0.287.9/engine/maya/maya2019/scripts', '/usr/autodesk/maya/plug-ins/camd/scripts', '/usr/autodesk/arnold/maya2019/scripts', '/opt/Allegorithmic/SubstanceMaya/2019/scripts', '/usr/autodesk/maya/plug-ins/xgen/scripts', '/home/suesauer/Documents/WorkspaceRefractor/install/RelWithDebInfo/plugin/al/lib/python', '/home/suesauer/Documents/WorkspaceRefractor/install/RelWithDebInfo/lib/python', '/home/suesauer/Documents/WorkspaceRefractor/install/RelWithDebInfo/plugin/pxr/lib/python', '/usr/autodesk/maya/lib/python27.zip', '/usr/autodesk/maya/lib/python2.7', '/usr/autodesk/maya/lib/python2.7/plat-linux2', '/usr/autodesk/maya/lib/python2.7/lib-tk', '/usr/autodesk/maya/lib/python2.7/lib-old', '/usr/autodesk/maya/lib/python2.7/lib-dynload', '/home/suesauer/.local/lib/python2.7/site-packages', '/usr/autodesk/maya/lib/python2.7/site-packages', '/usr/autodesk/maya/lib/python27.zip/lib-tk', u'/home/suesauer/maya/2019/prefs/scripts', u'/home/suesauer/maya/2019/scripts', u'/home/suesauer/maya/scripts', '/usr/autodesk/arnold/maya2019/scripts/mtoa/ui', '/usr/autodesk/arnold/maya2019/scripts/mtoa/ui', '/usr/autodesk/arnold/maya2019/scripts/mtoa/ui', '/usr/autodesk/arnold/maya2019/scripts/mtoa/ui', '/usr/autodesk/arnold/maya2019/extensions']

USD install:

/home/suesauer/Documents/USD

Python code run inside maya script editor:

import pxr.UsdQtEditors.outliner

Linux Centos 7 version: LSB Version: :core-4.1-amd64:core-4.1-noarch Distributor ID: CentOS Description: CentOS Linux release 7.7.1908 (Core) Release: 7.7.1908 Codename: Core

PS: It all seems to lead back to the _bindings.py

Thanks for helping Sue

suesauer commented 4 years ago

Just to add to above:

This is my build folder after compiling. It now contains the lib file in it. But I still get the same error regardless usdQt.tar.gz

my steps to compiling are:

mkdir /Documents/USD_QT cd /Documents/USD_QT git clone -b dev https://github.com/LumaPictures/usd-qt.git

BUILD

cd /Documents/USD_QT/usd-qt mkdir /Documents/USD_QT/usdQt cd /Documents/USD_QT/usdQt scl enable devtoolset-6 bash cmake /Documents/USD_QT/usd-qt -DCMAKE_INSTALL_PREFIX=/Documents/USD_QT/usdQt -DTBB_ROOT_DIR=/Documents/USD -DUSD_ROOT=/Documents/USD -DBOOST_ROOT=/Documents/USD/lib -DTBB_tbb_LIBRARY_RELEASE=/Documents/USD/lib/libtbb.so make install

..then I put the path to the lib file in my maya.env (this is everything in my maya.env file at the moment)

PYTHONPATH=/home/suesauer/Documents/USD_QT/usdQt/lib/python MAYA_MODULE_PATH=$MAYA_MODULE_PATH:/home/suesauer/maya/2019/build/RelWithDebInfo

USD ARNOLD

PYTHONPATH=$PYTHONPATH:/usr/lib/python2.7 PXR_PLUGINPATH_NAME=$PXR_PLGINPATH_NAME:/home/suesauer/Documents/Maya_arnold-usd/plugin LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib

nrusch commented 4 years ago

Hi @suesauer,

So the first thing I noticed is that the path in your Maya env file (/home/suesauer/Documents/USD_QT/usdQt/lib/python) is not on your sys.path in Maya. This would seem to indicate that perhaps that file is not being picked up.

I'm not a Maya expert, but looking at the documentation, the first thing that comes to mind is that the file name may be incorrect; you mentioned maya.env, but the file name is supposed to be title-case, as in Maya.env.

To test this, you can try manually prepending your UsdQt install path to PYTHONPATH before launching Maya. Assuming you use bash as your shell:

export PYTHONPATH=/home/suesauer/Documents/USD_QT/usdQt/lib/python:$PYTHONPATH
maya
suesauer commented 4 years ago

Hey there,

So checked all the above, still no dice.

In Maya script editor:

print sys.path ['/usr/autodesk/maya2019/bin', '/opt/pixar/RenderManForMaya-23.0/scripts', '/opt/pixar/RenderManProServer-23.0/bin', '/opt/pixar/RenderManProServer-23.0/lib/python2.7/site-packages', '/home/suesauer/Documents/USD_QT/usdQt/lib/python', '/home/suesauer/Documents/USD/lib/python', '/home/suesauer/Documents/WorkspaceRefractor/install/RelWithDebInfo/plugin/al/scripts', '/usr/autodesk/bifrost/maya2019/1.5.7.85/bifrost/scripts', '/usr/autodesk/maya2019/plug-ins/MASH/scripts', '/home/suesauer/Documents/WorkspaceRefractor/install/RelWithDebInfo/lib/scripts', '/home/suesauer/Documents/WorkspaceRefractor/install/RelWithDebInfo/plugin/adsk/scripts', '/home/suesauer/Documents/WorkspaceRefractor/install/RelWithDebInfo/scripts', '/home/suesauer/Documents/WorkspaceRefractor/install/RelWithDebInfo/plugin/pxr/scripts', '/home/suesauer/Documents/USD/scripts', '/usr/autodesk/maya2019/plug-ins/fbx/scripts', '/opt/hfs18.0.287.9/engine/maya/maya2019/scripts', '/usr/autodesk/maya2019/plug-ins/camd/scripts', '/usr/autodesk/arnold/maya2019/scripts', '/opt/Allegorithmic/SubstanceMaya/2019/scripts', '/usr/autodesk/maya2019/plug-ins/xgen/scripts', '/home/suesauer/Documents/WorkspaceRefractor/install/RelWithDebInfo/plugin/al/lib/python', '/home/suesauer/Documents/WorkspaceRefractor/install/RelWithDebInfo/lib/python', '/home/suesauer/Documents/WorkspaceRefractor/install/RelWithDebInfo/plugin/pxr/lib/python', '/home/suesauer/maya/2019', '/usr/autodesk/maya2019/lib/python27.zip', '/usr/autodesk/maya2019/lib/python2.7', '/usr/autodesk/maya2019/lib/python2.7/plat-linux2', '/usr/autodesk/maya2019/lib/python2.7/lib-tk', '/usr/autodesk/maya2019/lib/python2.7/lib-old', '/usr/autodesk/maya2019/lib/python2.7/lib-dynload', '/home/suesauer/.local/lib/python2.7/site-packages', '/usr/autodesk/maya2019/lib/python2.7/site-packages', '/usr/autodesk/maya2019/lib/python27.zip/lib-tk', u'/home/suesauer/maya/2019/prefs/scripts', u'/home/suesauer/maya/2019/scripts', u'/home/suesauer/maya/scripts', '/usr/autodesk/arnold/maya2019/scripts/mtoa/ui', '/usr/autodesk/arnold/maya2019/scripts/mtoa/ui', '/usr/autodesk/arnold/maya2019/scripts/mtoa/ui', '/usr/autodesk/arnold/maya2019/scripts/mtoa/ui', '/usr/autodesk/arnold/maya2019/extensions']

`import pxr.UsdQtEditors.outliner

Error: AttributeError: file /home/suesauer/Documents/USD_QT/usdQt/lib/python/pxr/UsdQt/_bindings.py line 25: 'NoneType' object has no attribute '__MFB_FULL_PACKAGE_NAME'

import pxr.UsdQtEditors.outliner

Error: ImportError: file /home/suesauer/Documents/USD_QT/usdQt/lib/python/pxr/UsdQt/hierarchyModel.py line 30: cannot import name _HierarchyCache # `

First time I run import it gives me the '__MFB_FULL_PACKAGE_NAME' error, second time I run it tells me cannot import name _HierarchyCache. Can see from my Maya.env file that "/home/suesauer/Documents/USD_QT/usdQt/lib/python" is there now.

Weird.... is there something I could be missing? Like pip wise?

suesauer commented 4 years ago

Hey there,

Side note, when I cd to the folder with the file _usdQt and try to run it:

$ python -c "import _usdQt" Warning: in Tf_PyLoadScriptModule at line 122 of /home/suesauer/Documents/USDPXR/USD/pxr/base/tf/pyUtils.cpp -- Import failed for module 'pxr.Tf'! Traceback (most recent call last): File "/home/suesauer/Documents/USD/lib/python/pxr/Tf/__init__.py", line 85, in <module> from . import _tf TypeError: No Python class registered for C++ class pxrInternal_v0_20__pxrReserved__::Tf_TypedPyEnumWrapper<pxrInternal_v0_20__pxrReserved__::TfDiagnosticType> Warning: in Tf_PyPostProcessModule at line 375 of /home/suesauer/Documents/USDPXR/USD/pxr/base/tf/pyModule.cpp -- Error occurred postprocessing module pxr.Trace._trace! TypeError: No Python class registered for C++ class pxrInternal_v0_20__pxrReserved__::TraceReporter Warning: in Tf_PyLoadScriptModule at line 122 of /home/suesauer/Documents/USDPXR/USD/pxr/base/tf/pyUtils.cpp -- Import failed for module 'pxr.Trace'! Traceback (most recent call last): File "/home/suesauer/Documents/USD/lib/python/pxr/Trace/__init__.py", line 29, in <module> from pxr import Tf File "/home/suesauer/Documents/USD/lib/python/pxr/Tf/__init__.py", line 98, in <module> __SetErrorExceptionClass(ErrorException) NameError: name '__SetErrorExceptionClass' is not defined Warning: in Tf_PyLoadScriptModule at line 122 of /home/suesauer/Documents/USDPXR/USD/pxr/base/tf/pyUtils.cpp -- Import failed for module 'pxr.Work'! Traceback (most recent call last): File "/home/suesauer/Documents/USD/lib/python/pxr/Work/__init__.py", line 32, in <module> from pxr import Tf File "/home/suesauer/Documents/USD/lib/python/pxr/Tf/__init__.py", line 98, in <module> __SetErrorExceptionClass(ErrorException) NameError: name '__SetErrorExceptionClass' is not defined Warning: in Tf_PyLoadScriptModule at line 122 of /home/suesauer/Documents/USDPXR/USD/pxr/base/tf/pyUtils.cpp -- Import failed for module 'pxr.Plug'! Traceback (most recent call last): File "/home/suesauer/Documents/USD/lib/python/pxr/Plug/__init__.py", line 28, in <module> import _plug RuntimeError: extension class wrapper for base class pxrInternal_v0_20__pxrReserved__::TfNotice has not been created yet Warning: in Tf_PyLoadScriptModule at line 122 of /home/suesauer/Documents/USDPXR/USD/pxr/base/tf/pyUtils.cpp -- Import failed for module 'pxr.Gf'! Traceback (most recent call last): File "/home/suesauer/Documents/USD/lib/python/pxr/Gf/__init__.py", line 31, in <module> from pxr import Tf File "/home/suesauer/Documents/USD/lib/python/pxr/Tf/__init__.py", line 98, in <module> __SetErrorExceptionClass(ErrorException) NameError: name '__SetErrorExceptionClass' is not defined Warning: in Tf_PyLoadScriptModule at line 122 of /home/suesauer/Documents/USDPXR/USD/pxr/base/tf/pyUtils.cpp -- Import failed for module 'pxr.Vt'! Traceback (most recent call last): File "/home/suesauer/Documents/USD/lib/python/pxr/Vt/__init__.py", line 32, in <module> from pxr import Tf File "/home/suesauer/Documents/USD/lib/python/pxr/Tf/__init__.py", line 98, in <module> __SetErrorExceptionClass(ErrorException) NameError: name '__SetErrorExceptionClass' is not defined Warning: in Tf_PyLoadScriptModule at line 122 of /home/suesauer/Documents/USDPXR/USD/pxr/base/tf/pyUtils.cpp -- Import failed for module 'pxr.Ar'! Traceback (most recent call last): File "/home/suesauer/Documents/USD/lib/python/pxr/Ar/__init__.py", line 25, in <module> from pxr import Tf File "/home/suesauer/Documents/USD/lib/python/pxr/Tf/__init__.py", line 98, in <module> __SetErrorExceptionClass(ErrorException) NameError: name '__SetErrorExceptionClass' is not defined Warning: in Tf_PyLoadScriptModule at line 122 of /home/suesauer/Documents/USDPXR/USD/pxr/base/tf/pyUtils.cpp -- Import failed for module 'pxr.Sdf'! Traceback (most recent call last): File "/home/suesauer/Documents/USD/lib/python/pxr/Sdf/__init__.py", line 24, in <module> import _sdf TypeError: No to_python (by-value) converter found for C++ type: pxrInternal_v0_20__pxrReserved__::TfToken Warning: in Tf_PyLoadScriptModule at line 122 of /home/suesauer/Documents/USDPXR/USD/pxr/base/tf/pyUtils.cpp -- Import failed for module 'pxr.Kind'! Traceback (most recent call last): File "/home/suesauer/Documents/USD/lib/python/pxr/Kind/__init__.py", line 27, in <module> from pxr import Tf File "/home/suesauer/Documents/USD/lib/python/pxr/Tf/__init__.py", line 98, in <module> __SetErrorExceptionClass(ErrorException) NameError: name '__SetErrorExceptionClass' is not defined Warning: in Tf_PyLoadScriptModule at line 122 of /home/suesauer/Documents/USDPXR/USD/pxr/base/tf/pyUtils.cpp -- Import failed for module 'pxr.Pcp'! Traceback (most recent call last): File "/home/suesauer/Documents/USD/lib/python/pxr/Pcp/__init__.py", line 24, in <module> import _pcp TypeError: No Python class registered for C++ class pxrInternal_v0_20__pxrReserved__::Tf_TypedPyEnumWrapper<pxrInternal_v0_20__pxrReserved__::PcpDependencyType> Warning: in Tf_PyLoadScriptModule at line 122 of /home/suesauer/Documents/USDPXR/USD/pxr/base/tf/pyUtils.cpp -- Import failed for module 'pxr.Usd'! Traceback (most recent call last): File "/home/suesauer/Documents/USD/lib/python/pxr/Usd/__init__.py", line 24, in <module> import _usd TypeError: No Python class registered for C++ class pxrInternal_v0_20__pxrReserved__::Tf_TypedPyEnumWrapper<pxrInternal_v0_20__pxrReserved__::UsdListPosition> Traceback (most recent call last): File "<string>", line 1, in <module> RuntimeError: extension class wrapper for base class pxrInternal_v0_20__pxrReserved__::TfNotice has not been created yet

nrusch commented 4 years ago

OK, so after putting UsdQt on PYTHONPATH, you're getting a different error than before. I guess that's some kind of progress...

This appears to be some sort of an issue with your environment, but without knowing everything you might have built, installed, etc. the best I can really do is guess. I've never heard of the the __MFB_FULL_PACKAGE_NAME error before, so I can only assume it's something Maya-specific...

Also, looking at all of the errors in your last message, they're all referencing /home/suesauer/Documents/USDPXR, which doesn't match any path on sys.path (in Maya). Do you happen to have multiple USD builds in your home directory?

Two questions I guess I would have next are:

suesauer commented 4 years ago

Hey me again,

On the __MFB_FULL_PACKAGE_NAME topic:

https://github.com/PixarAnimationStudios/USD/issues/1033 and, https://github.com/LumaPictures/usd-qt/issues/22

Seems to be a thing with centos 7 maybe or more then one python.

On the /home/suesauer/Documents/USDPXR topic:

That is where all the .cpp and .h files are that TF is trying to wrap onto with python I assume.

Your two questions

  1. When I run import pxr.UsdQt as a standalone see video, 2020-01-31 10-58-29.mkv.tar.gz maybe I'm doing it wrong? But nothing happens other then the mouse turning into a little cross head, when I click on the screen it vanishes and there are no errors.

  2. Not sure how to get a print out of LD_LIBRARY_PATH in Maya. In the terminal it says: LD_LIBRARY_PATH=::/home/suesauer/Documents/USD/lib

Side note
Seems to hate:

__SetErrorExceptionClass(ErrorException) says is not defined Warning if I # that out half the erros go away. See pic of where it is. Screenshot from 2020-01-31 11-10-38

Python class warnings

Then only the TypeError: No Python class registered for C++ class warnings remain. I assume that I need to somehow tell all my builds what python to use? Only I have no idea which python is best. At the moment I'm using: Python 2.7.5 (default, Aug 7 2019, 00:51:29) [GCC 4.8.5 20150623 (Red Hat 4.8.5-39)] on linux2 I also have no idea how to tell the builds what python to use explicitly if there is a conflict, haven't needed to do this before now.

In USD pyUtils.h:

We find: #define TF_PY_REPR_PREFIX \ std::string(BOOST_PP_STRINGIZE(MFB_PACKAGE_MODULE) ".") Screenshot from 2020-01-31 12-24-14

I think I need to link this on the USD github page as well. Seems to be a bigger issue then I first thought.

nrusch commented 4 years ago

OK, so there are quite a few variables here that we can't really control for, but because of the No Python class registered for C++ class errors (which are from Boost Python), I'm fairly confident this is an issue with your USD build and/or build environment.

I've been assuming that you are able to import and use the USD python bindings in your standalone interpreter, but can you confirm that this is the case?

To see the value of LD_LIBRARY_PATH in Maya, you can use print os.environ['LD_LIBRARY_PATH']. If you get a KeyError, that means it's unset.

suesauer commented 4 years ago

Hello again,

USD build and/or build environment

At the moment I have no venv setups, nothing special at all. Just followed the documentation as is. That being said, here are some images of what's installed on the pc in general

Pip

Screenshot from 2020-02-03 10-54-29

Boost

Boost version: 1.53.0 Is the boost version on my system according to the terminal.


Standalone interpreter

Looking into the interpreter now, didn't test it as a stand alone. Was just going straight into maya with the maya-usd. USDview works just fine for me tho, so I just "assume" it was fine.


LD_LIBRARY_PATH

print os.environ['LD_LIBRARY_PATH'] /usr/autodesk/maya/lib::/home/suesauer/Documents/USD/lib

suesauer commented 4 years ago

Figured this out, was my Houdini Envs messing with this. Solved by making maya its own shell run script