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 on macOS 10.14.6 - ImportError: cannot import name QtCore #1111

Closed
sttng opened this issue Feb 10, 2020 · 20 comments
Closed

usdview on macOS 10.14.6 - ImportError: cannot import name QtCore #1111

sttng opened this issue Feb 10, 2020 · 20 comments

Comments

@sttng
Copy link

sttng commented Feb 10, 2020

Description of Issue

Starting usdview will fail with ImportError:

Traceback (most recent call last):
  File "/opt/local/USD/bin/usdview", line 28, in <module>
    import pxr.Usdviewq as Usdviewq
  File "/opt/local/USD/lib/python/pxr/Usdviewq/__init__.py", line 26, in <module>
    from qt import QtWidgets
  File "/opt/local/USD/lib/python/pxr/Usdviewq/qt.py", line 26, in <module>
    from attributeValueEditorUI import QtCore
ImportError: cannot import name QtCore

Fix (for me)

Replacing the line below:

https://github.com/PixarAnimationStudios/USD/blob/be1a80f8cb91133ac75e1fc2a2e1832cd10d91c8/pxr/usdImaging/usdviewq/qt.py#L26

with

from PySide2 import QtCore

fixed the issue and usdview starts on macOS for me.

Steps to Reproduce

Install USD on macOS by following the instructions
Test the installation by running:
usdview extras/usd/tutorials/convertingLayerFormats/Sphere.usda

System Information (OS, Hardware)

macOS 10.14.6 (fresh install)

Package Versions

Not sure about the version, cloned the master branch from Github on 10th Feb 2020

Build Flags

python USD/build_scripts/build_usd.py /opt/local/USD

@moddyz
Copy link
Contributor

moddyz commented Feb 10, 2020

Out of curiousity - if you add the following lines before from attributeValueEditorUI import QtCore:

import attributeValueEditorUI
print attributeValueEditorUI.__file__

What output do you see?

@jilliene
Copy link

Filed as internal issue #USD-5847

@sttng
Copy link
Author

sttng commented Feb 11, 2020

Out of curiousity - if you add the following lines before from attributeValueEditorUI import QtCore:

import attributeValueEditorUI
print attributeValueEditorUI.__file__

What output do you see?

Thats the output (in fact no output from those lines as far as I can see):

Tors-MBP:Pixar tor$ usdview
dyld: warning, LC_RPATH @executable_path/../Frameworks in /Library/Python/2.7/site-packages/PySide2/Qt/lib/QtQml.framework/Versions/5/QtQml being ignored in restricted program because of @executable_path
dyld: warning, LC_RPATH @executable_path/../Frameworks in /Library/Python/2.7/site-packages/PySide2/Qt/lib/QtNetwork.framework/Versions/5/QtNetwork being ignored in restricted program because of @executable_path
dyld: warning, LC_RPATH @executable_path/../Frameworks in /Library/Python/2.7/site-packages/PySide2/Qt/lib/QtCore.framework/Versions/5/QtCore being ignored in restricted program because of @executable_path
dyld: warning, LC_RPATH @executable_path/../Frameworks in /Library/Python/2.7/site-packages/PySide2/Qt/lib/QtGui.framework/Versions/5/QtGui being ignored in restricted program because of @executable_path
dyld: warning, LC_RPATH @executable_path/../Frameworks in /Library/Python/2.7/site-packages/PySide2/Qt/lib/QtWidgets.framework/Versions/5/QtWidgets being ignored in restricted program because of @executable_path
/opt/local/USD/lib/python/pxr/Usdviewq/attributeValueEditorUI.pyc
Traceback (most recent call last):
  File "/opt/local/USD/bin/usdview", line 28, in <module>
    import pxr.Usdviewq as Usdviewq
  File "/opt/local/USD/lib/python/pxr/Usdviewq/__init__.py", line 26, in <module>
    from qt import QtWidgets
  File "/opt/local/USD/lib/python/pxr/Usdviewq/qt.py", line 28, in <module>
    from attributeValueEditorUI import QtCore
ImportError: cannot import name QtCore
Tors-MBP:Pixar tor$ 

@RyZeePy
Copy link

RyZeePy commented Feb 15, 2020

I'm hitting this same issue.
It seems that .../lib/python/pxr/Usdviewq/attributeValueEditorUI.py (generated by uic) does not import QtCore directly into it's global scope. The imports are as below:

from PySide2.QtCore import (QCoreApplication, QMetaObject, QObject, QPoint,
    QRect, QSize, QUrl, Qt)
from PySide2.QtGui import (QBrush, QColor, QConicalGradient, QCursor, QFont,
    QFontDatabase, QIcon, QLinearGradient, QPalette, QPainter, QPixmap,
    QRadialGradient)
from PySide2.QtWidgets import *

Perhaps imports are being generated differently by uic in newer versions of PySide2?

Using:
Fedora 31 (kernel 5.4.17-200.fc31.x86_64)
USD-20.02
PySide2-5.14.1

Can provide more info upon request.

@danlee-lils
Copy link

I am getting the same issue here...

@sunyab
Copy link
Contributor

sunyab commented Feb 19, 2020

Hi all, thanks for the reports, we're observed this issue on our side as well and are looking into a fix. For the folks who are running into this, are you using PySide2 5.14.1? The test environment where we're hitting this is using 5.14.1, and I see @Seymour88 is as well.

@danlee-lils
Copy link

Yes I am using pyside2 5.14.1.

@meshula
Copy link
Member

meshula commented Feb 19, 2020

I can confirm from multiple sources that 5.13.2 is the latest that works on macOS, later than that, it's broken.

@danlee-lils
Copy link

cool thank you for the information!!

@robpieke
Copy link
Contributor

robpieke commented Feb 21, 2020

I can confirm from multiple sources that 5.13.2 is the latest that works on macOS, later than that, it's broken.

They (Qt) switched from a bespoke pyside2-uic to uic (with python support) in 5.14

https://bugreports.qt.io/browse/PYSIDE-1098
https://github.com/qt/qtbase/blob/dev/src/tools/uic/python/pythonwriteimports.cpp#L41

@sttng
Copy link
Author

sttng commented Feb 22, 2020

Yeah also using PySide2 5.14.1 (https://download.qt.io/official_releases/QtForPython/pyside2/PySide2-5.14.1-5.14.1-cp27-cp27m-macosx_10_13_intel.whl) here. That seems to be the culprit.

@jackiezxt
Copy link

I'm hitting the same issue on macOS 10.15, but I was successfully built the usd-core on win10 with flags like this
python build_usd.py C:\USD --build-args boost,"--with-date_time --with-thread --with-system --with-filesystem"
but I faild on macos with
python USD/build_scripts/build_usd.py /opt/local/USD
they are the same branch from GitHub......

USD-20.02
PySide2-5.14.1
macOS-10.15 catalina

@sttng
Copy link
Author

sttng commented Feb 24, 2020

I'm hitting the same issue on macOS 10.15, but I was successfully built the usd-core on win10 with flags like this
python build_usd.py C:\USD --build-args boost,"--with-date_time --with-thread --with-system --with-filesystem"
but I faild on macos with
python USD/build_scripts/build_usd.py /opt/local/USD
they are the same branch from GitHub......

USD-20.02
PySide2-5.14.1
macOS-10.15 catalina

I guess if your build fails this is a Python 2 vs Python 3 issue. Catalina comes with Python 3 standard, and USD still relies on Python 2.
Anyhow the issue dicsussion here is not a issue of failed building (actually the build is successful), but an issue in running usdview - after successful build. I suggest to create a new issue and add the output of errors you receive from building.

@jackiezxt
Copy link

Hi, @sttng
I'm running python 2.7.16, the same running usdview error after successful build on macos

@danlee-lils
Copy link

danlee-lils commented Feb 24, 2020

downgrade your pyside2 to 5.13.2 and rebuild the whole USD and it should work.

@jackiezxt
Copy link

downgrade your pyside2 to 5.13.2 and rebuild the whole USD and it should work.

Thank you @danlee-lils, Bingo!, it's done, I pip uninstall the 5.14.1, and pip install the pyside2==5.13.2, usdview became alive and works.

@sunyab
Copy link
Contributor

sunyab commented Feb 25, 2020

We have a fix for this issue checked in internally and will be pushing out to GitHub in the next few days.

@aka-anoop
Copy link

downgrade your pyside2 to 5.13.2 and rebuild the whole USD and it should work.

Works like a charm. Thank you.

Will wait for the fix as well @sunyab 👍

@spitzak
Copy link

spitzak commented Jan 8, 2021

This is a failure in the code to detect whether PySide or PySide2 is in use that does not work for PySide2 after 5.13. Removing the test will make it unable to work with one of these. My proposed patch to qt.py:

@@ -23,9 +23,13 @@
 #
 
 # Import a UI file generated by the build to detect which version of PySide to use.
-from attributeValueEditorUI import QtCore
+try:
+    from attributeValueEditorUI import QtCore
+    pyside1 = QtCore.__name__.startswith('PySide.')
+except:
+    pyside1 = False
 
-if QtCore.__name__.startswith('PySide.'):
+if pyside1:
     from PySide import QtGui, QtOpenGL
     from PySide import QtGui as QtWidgets
 
@@ -53,13 +57,11 @@
     if not hasattr(QtCore, 'QStringListModel'):
         QtCore.QStringListModel = QtGui.QStringListModel
 
-elif QtCore.__name__.startswith('PySide2.'):
-    from PySide2 import QtGui, QtWidgets, QtOpenGL
+else:
+    from PySide2 import QtCore, QtGui, QtWidgets, QtOpenGL
     
     # Older versions still have QtGui.QStringListModel - this
     # is apparently a bug:
     #    https://bugreports.qt.io/browse/PYSIDE-614
     if not hasattr(QtCore, 'QStringListModel'):
         QtCore.QStringListModel = QtGui.QStringListModel
-else:
-    raise ImportError()

@brainteaser1990
Copy link

I got this error again, any solutions ??

usdview -h
Traceback (most recent call last):
File "/usr/local/USD/bin/usdview", line 28, in
import pxr.Usdviewq as Usdviewq
File "/usr/local/USD/lib/python/pxr/Usdviewq/init.py", line 32, in
from .qt import QtWidgets, QtCore
File "/usr/local/USD/lib/python/pxr/Usdviewq/qt.py", line 42, in
PySideModule = GetPySideModule()
File "/usr/local/USD/lib/python/pxr/Usdviewq/qt.py", line 31, in GetPySideModule
from . import attributeValueEditorUI
File "/usr/local/USD/lib/python/pxr/Usdviewq/attributeValueEditorUI.py", line 1
/********************************************************************************
^
SyntaxError: invalid syntax

not working with the pyside2 version change as well.

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