OpenUSD icon indicating copy to clipboard operation
OpenUSD copied to clipboard

usdview: No module named 'pxr'

Open mrandrewpettit opened this issue 2 years ago • 5 comments

Description of Issue/Steps to Reproduce

Hi, I was able to successfully build USD using the build script. And set the needed environment variables. But when I run this command I get this error:

usdview extras/usd/tutorials/convertingLayerFormats/Sphere.usda

Traceback (most recent call last): File "/usr/local/USD/bin/usdview", line 28, in import pxr.Usdviewq as Usdviewq ModuleNotFoundError: No module named 'pxr'

I checked to make sure /usr/local/USD/lib/python/pxr exists, and it does so maybe I didn't set my environment variables correctly? This is them:

$PATH=/usr/local/USD/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/lib/wsl/lib:/snap/bin $PYTHONPATH=/usr/local/USD/lib/python

They seemed right, so perhaps it is a compile error?

Package Versions/System Info

These are the specs I ran the build with: Ubuntu 20.04 Python 3.8.10 gcc 9.4.0 cmake 3.16.3 PySide2 5.15.2.1 PyOpenGL 3.1.6

I know these aren't the tested specs but it's the only build I've successfully built on ubuntu. It's also worth mentioning that I am attempting to do this via WSL on windows.

Anyone has an idea of where I can look for the issue? Thank you!

mrandrewpettit avatar Oct 02 '22 20:10 mrandrewpettit

Filed as internal issue #USD-7670

tallytalwar avatar Oct 03 '22 17:10 tallytalwar

@andrewp2010 I'm not really sure what's going on here, what do the contents of /usr/local/USD/lib/python look like? Are you able to just do "from pxr import Usd" in a Python interpreter? You might also try running python -c "import sys; print(sys.path)" to verify that the USD directory is being picked up in your module search path.

sunyab avatar Oct 17 '22 16:10 sunyab

I have the same issue, everything else seems fine

daniloganzella@Mini-de-Danilo ~ % echo $PATH            
/usr/local/opt/llvm/bin:/opt/local/USD/bin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/local/USD/bin:/opt/local/USD/lib/python:/opt/local/USD/lib:/usr/local/share/dotnet:~/.dotnet/tools:/Library/Apple/usr/bin:/Library/Frameworks/Mono.framework/Versions/Current/Commands:/Users/daniloganzella/Downloads/flutter/bin
daniloganzella@Mini-de-Danilo ~ % echo $PYTHONPATH
/usr/local/bin/python3
daniloganzella@Mini-de-Danilo ~ % usdview ./extras/usd/tutorials/convertingLayerFormats/Sphere.usda     
Traceback (most recent call last):
  File "/opt/local/USD/bin/usdview", line 28, in <module>
    import pxr.Usdviewq as Usdviewq
ModuleNotFoundError: No module named 'pxr'

I can use usdtree though

daniloganzella@Mini-de-Danilo ~ % cd Desktop 
daniloganzella@Mini-de-Danilo Desktop % cd USD-release 
daniloganzella@Mini-de-Danilo USD-release % usdtree ./extras/usd/tutorials/convertingLayerFormats/Sphere.usda
/
 `--sphere [def Sphere]
daniloganzella@Mini-de-Danilo USD-release % 

dganzella avatar Mar 01 '23 17:03 dganzella

k, was able to run it. the issue was that PYTHONPATH was wrong, it needs to be /opt/local/USD/lib/python and not python binary itself.

my bad!!

dganzella avatar Mar 01 '23 17:03 dganzella

Sharing a helpful comment from @pablode from #2080 (which we've closed as a duplicate of this issue)

I found that PYTHONPATH=/opt/local/USD/lib/python is not enough; you need to export PYTHONPATH=/opt/local/USD/lib/python so that it is visible to child processes.

pixar-oss avatar Apr 01 '24 16:04 pixar-oss

Has anyone encountered this bug on Windows with Python versions of various natures? I Have Python 3.11 installed and in default system path via env var.

C:\usd>python -c "import sys; print(sys.path)" ['', 'C:\\Program Files\\Python311\\python311.zip', 'C:\\Program Files\\Python311\\DLLs', 'C:\\Program Files\\Python311\\Lib', 'C:\\Program Files\\Python311', 'C:\\Users\\dnelson3\\AppData\\Roaming\\Python\\Python311\\site-packages', 'C:\\Program Files\\Python311\\Lib\\site-packages']

`(venv) C:\Program Files\Python311\Lib\site-packages\pxr>usdview Traceback (most recent call last): File "c:\usd\bin\usdview", line 28, in import pxr.Usdviewq as Usdviewq ModuleNotFoundError: No module named 'pxr'

(venv) C:\Program Files\Python311\Lib\site-packages\pxr>ipython C:\Program Files\Python311\Lib\site-packages\IPython\core\interactiveshell.py:937: UserWarning: Attempting to work in a virtualenv. If you encounter problems, please install IPython inside the virtualenv. warn( Python 3.11.9 (tags/v3.11.9:de54cf5, Apr 2 2024, 10:12:12) [MSC v.1938 64 bit (AMD64)] Type 'copyright', 'credits' or 'license' for more information IPython 8.22.2 -- An enhanced Interactive Python. Type '?' for help.

In [1]: import pxr

In [2]: import pxr.Usdviewq as Usdviewq

ModuleNotFoundError Traceback (most recent call last) Cell In[2], line 1 ----> 1 import pxr.Usdviewq as Usdviewq

ModuleNotFoundError: No module named 'pxr.Usdviewq'`

Curious about the windows equivalent of export PYTHONPATH.

I have no other listing on pxr other than site-packages in C:\Program Files\Python311\Lib\site-packages\pxr where my default Python311 is installed and I get this in default command or with venv I setup like anaconda, which also has no other pxr site references.

`(venv) C:\Program Files\Python311\Lib\site-packages\pxr>dir Volume in drive C is primary Volume Serial Number is B8FA-2D43

Directory of C:\Program Files\Python311\Lib\site-packages\pxr

03/12/2024 11:54 AM <DIR> . 03/12/2024 11:54 AM <DIR> .. 03/12/2024 11:54 AM <DIR> Ar 03/12/2024 11:54 AM 17,408 boost_atomic-vc142-mt-x64-1_82.dll 03/12/2024 11:54 AM 193,024 boost_python311-vc142-mt-x64-1_82.dll 03/12/2024 11:54 AM 229,376 boost_regex-vc142-mt-x64-1_82.dll 03/12/2024 11:54 AM <DIR> Gf 03/12/2024 11:54 AM <DIR> Kind 03/12/2024 11:54 AM <DIR> Ndr 03/12/2024 11:54 AM <DIR> Pcp 03/12/2024 11:54 AM <DIR> Plug 03/12/2024 11:54 AM <DIR> pluginfo 03/12/2024 11:54 AM <DIR> Sdf 03/12/2024 11:54 AM <DIR> Sdr 03/12/2024 11:54 AM 401,280 tbb.dll 03/12/2024 11:54 AM 74,112 tbbbind.dll 03/12/2024 11:54 AM 86,400 tbbbind_debug.dll 03/12/2024 11:54 AM 246,656 tbbmalloc.dll 03/12/2024 11:54 AM 214,912 tbbmalloc_debug.dll 03/12/2024 11:54 AM 107,392 tbbmalloc_proxy.dll 03/12/2024 11:54 AM 56,192 tbbmalloc_proxy_debug.dll 03/12/2024 11:54 AM 635,264 tbb_debug.dll 03/12/2024 11:54 AM 417,152 tbb_preview.dll 03/12/2024 11:54 AM 682,880 tbb_preview_debug.dll 03/12/2024 11:54 AM <DIR> Tf 03/12/2024 11:54 AM <DIR> Trace 03/12/2024 11:54 AM <DIR> Ts 03/12/2024 11:54 AM <DIR> Usd 03/12/2024 11:54 AM <DIR> UsdGeom 03/12/2024 11:54 AM <DIR> UsdHydra 03/12/2024 11:54 AM <DIR> UsdLux 03/12/2024 11:54 AM <DIR> UsdMedia 03/12/2024 11:54 AM <DIR> UsdPhysics 03/12/2024 11:54 AM <DIR> UsdProc 03/12/2024 11:54 AM <DIR> UsdRender 03/12/2024 11:54 AM <DIR> UsdRi 03/12/2024 11:54 AM <DIR> UsdShade 03/12/2024 11:54 AM <DIR> UsdSkel 03/12/2024 11:54 AM <DIR> UsdUI 03/12/2024 11:54 AM <DIR> UsdUtils 03/12/2024 11:54 AM <DIR> UsdVol 03/12/2024 11:54 AM 217,600 usd_ar.dll 03/12/2024 11:54 AM 181,760 usd_arch.dll 03/12/2024 11:54 AM 573,952 usd_gf.dll 03/12/2024 11:54 AM 91,648 usd_js.dll 03/12/2024 11:54 AM 44,032 usd_kind.dll 03/12/2024 11:54 AM 170,496 usd_ndr.dll 03/12/2024 11:54 AM 1,266,176 usd_pcp.dll 03/12/2024 11:54 AM 236,544 usd_plug.dll 03/12/2024 11:54 AM 4,138,496 usd_sdf.dll 03/12/2024 11:54 AM 154,112 usd_sdr.dll 03/12/2024 11:54 AM 830,976 usd_tf.dll 03/12/2024 11:54 AM 274,944 usd_trace.dll 03/12/2024 11:54 AM 618,496 usd_ts.dll 03/12/2024 11:54 AM 4,781,568 usd_usd.dll 03/12/2024 11:54 AM 1,182,720 usd_usdGeom.dll 03/12/2024 11:54 AM 77,824 usd_usdHydra.dll 03/12/2024 11:54 AM 341,504 usd_usdLux.dll 03/12/2024 11:54 AM 79,872 usd_usdMedia.dll 03/12/2024 11:54 AM 280,576 usd_usdPhysics.dll 03/12/2024 11:54 AM 40,448 usd_usdProc.dll 03/12/2024 11:54 AM 139,776 usd_usdRender.dll 03/12/2024 11:54 AM 143,360 usd_usdRi.dll 03/12/2024 11:54 AM 573,440 usd_usdShade.dll 03/12/2024 11:54 AM 1,027,072 usd_usdSkel.dll 03/12/2024 11:54 AM 63,488 usd_usdUI.dll 03/12/2024 11:54 AM 711,168 usd_usdUtils.dll 03/12/2024 11:54 AM 89,088 usd_usdVol.dll 03/12/2024 11:54 AM 1,450,496 usd_vt.dll 03/12/2024 11:54 AM 30,208 usd_work.dll 03/12/2024 11:54 AM <DIR> Vt 03/12/2024 11:54 AM <DIR> Work 03/12/2024 11:54 AM 83,968 zlib.dll 03/12/2024 11:54 AM 1,008 init.py 03/12/2024 11:54 AM <DIR> pycache 44 File(s) 23,258,864 bytes 31 Dir(s) 316,523,778,048 bytes free

(venv) C:\Program Files\Python311\Lib\site-packages\pxr>`

`PS C:\Users\dnelson3\AppData\Roaming\Python\Python311\site-packages> dir

Directory: C:\Users\dnelson3\AppData\Roaming\Python\Python311\site-packages

Mode LastWriteTime Length Name


d----- 3/14/2024 4:12 PM OpenGL d----- 3/14/2024 4:13 PM PyOpenGL-3.1.7.dist-info

PS C:\Users\dnelson3\AppData\Roaming\Python\Python311\site-packages>`

Obliged for the assistance. Thanks, -David.

@david-dot-nelson-2-at-sony-dot-com How did you build and install OpenUSD on your system? From your directory listing, it appears that none of the imaging components (including usdview) are present in your site-packages/pxr directory. Do you have a different build of OpenUSD somewhere else?

sunyab avatar May 07 '24 15:05 sunyab

Sure thing. I have Autodesk and Houdini installed from their respective installers for USD on this system. I had installed OpenUSD previously with Python3.9 but ran into this error ( #3009 / #2996 ), which I got to run properly with PySide correction. But I hit issues with global environment variable conflicts with usd python versions with Python 3.9 and with Houdini. So I have attempted to correct my system, by removing Python 3.9 from PYTHONPATH and installing OpenUSD with only Python 3.11 in the Python path.

Here's my steps on the latest install:

  1. Install Microsoft Visual Studio 2022
  2. Install OpenUSD from git
  3. Install Python 3.11
  4. Download USD from https://github.com/PixarAnimationStudios/OpenUSD
  5. Install Python 3.11 from python.org
  6. Open Developer Command Prompt as Admin from Start Menu
  7. python -m pip install virtualenv
  8. cd D:\Github\
  9. git clone https://github.com/PixarAnimationStudios/OpenUSD.git
  10. C:
  11. cd \
  12. mkdir venv
  13. python -m venv c:\venv
  14. C:\venv\Scripts\activate.bat
  15. python -m pip install pyside6 pyopengl
  16. D:\Github\OpenUSD>python .\build_scripts\build_usd.py c:\usd

********************************************************************** ** Visual Studio 2022 Developer Command Prompt v17.9.6 ** Copyright (c) 2022 Microsoft Corporation **********************************************************************

C:\Windows\System32>d:

D:\>cd Github\OpenUSD

D:\Github\OpenUSD>python .\build_scripts\build_usd.py c:\usd

Building with settings: USD source directory D:\Github\OpenUSD USD install directory c:\usd 3rd-party source directory c:\usd\src 3rd-party install directory c:\usd Build directory c:\usd\build CMake generator Default CMake toolset Default Downloader curl

Building Shared libraries Variant Release Target Imaging On Ptex support: Off OpenVDB support: Off OpenImageIO support: Off OpenColorIO support: Off PRMan support: Off UsdImaging On usdview: On Python support On Python Debug: Off Python docs: Off Documentation Off Tests Off Mayapy Tests: Off AnimX Tests: Off Examples On Tutorials On Tools On Alembic Plugin Off HDF5 support: Off Draco Plugin Off MaterialX Plugin On

Dependencies None STATUS: Installing USD...

Success! To use USD, please ensure that you have:

The following in your PYTHONPATH environment variable: c:\usd\lib\python

The following in your PATH environment variable: c:\usd\bin c:\usd\lib

D:\Github\OpenUSD>

I am not sure where it is going wrong. Thanks for your help. -David.

@sunyab Oh, SMH. It was right in my face. Somehow the Py 3.9 installation had covered the PYTHONPATH setup and removing it cleared the path when setting up Py 3.11 exclusively.

The following in your PYTHONPATH environment variable: c:\usd\lib\python

So I added PYTHONPATH to sys env vars as C:\usd\lib\python;C:\Program Files\Python311;C:\Program Files\Python311\Lib\site-packages

And it works. I still have a viewer problem which I think still relates to #3009, and I think I will jump back to that for the PySide in Py 3.11 for correction.

Thank you for your time! Cheers. -David.

Glad you found a solution! Thanks for sharing the update :)

jesschimein avatar May 07 '24 20:05 jesschimein