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

usdview: No module named 'pxr' #2054

Closed
mrandrewpettit opened this issue Oct 2, 2022 · 10 comments
Closed

usdview: No module named 'pxr' #2054

mrandrewpettit opened this issue Oct 2, 2022 · 10 comments

Comments

@mrandrewpettit
Copy link

mrandrewpettit commented Oct 2, 2022

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!

@tallytalwar
Copy link
Contributor

Filed as internal issue #USD-7670

@sunyab
Copy link
Contributor

sunyab commented Oct 17, 2022

@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.

@dganzella
Copy link

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
Copy link

dganzella commented Mar 1, 2023

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!!

@pixar-oss
Copy link
Member

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.

@david-dot-nelson-2-at-sony-dot-com

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

.
03/12/2024 11:54 AM ..
03/12/2024 11:54 AM 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 Gf
03/12/2024 11:54 AM Kind
03/12/2024 11:54 AM Ndr
03/12/2024 11:54 AM Pcp
03/12/2024 11:54 AM Plug
03/12/2024 11:54 AM pluginfo
03/12/2024 11:54 AM Sdf
03/12/2024 11:54 AM 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 Tf
03/12/2024 11:54 AM Trace
03/12/2024 11:54 AM Ts
03/12/2024 11:54 AM Usd
03/12/2024 11:54 AM UsdGeom
03/12/2024 11:54 AM UsdHydra
03/12/2024 11:54 AM UsdLux
03/12/2024 11:54 AM UsdMedia
03/12/2024 11:54 AM UsdPhysics
03/12/2024 11:54 AM UsdProc
03/12/2024 11:54 AM UsdRender
03/12/2024 11:54 AM UsdRi
03/12/2024 11:54 AM UsdShade
03/12/2024 11:54 AM UsdSkel
03/12/2024 11:54 AM UsdUI
03/12/2024 11:54 AM UsdUtils
03/12/2024 11:54 AM 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 Vt
03/12/2024 11:54 AM 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 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.

@sunyab
Copy link
Contributor

sunyab commented May 7, 2024

@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?

@david-dot-nelson-2-at-sony-dot-com
Copy link

david-dot-nelson-2-at-sony-dot-com commented May 7, 2024

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.

@david-dot-nelson-2-at-sony-dot-com
Copy link

david-dot-nelson-2-at-sony-dot-com commented May 7, 2024

@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.

@jesschimein
Copy link
Contributor

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

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

7 participants