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

Python crashed. FATAL ERROR: Failed axiom: ' Py_IsInitialized() ' #1620

Closed
aaronn opened this issue Sep 15, 2021 · 8 comments
Closed

Python crashed. FATAL ERROR: Failed axiom: ' Py_IsInitialized() ' #1620

aaronn opened this issue Sep 15, 2021 · 8 comments

Comments

@aaronn
Copy link

aaronn commented Sep 15, 2021

Description of Issue

Hey everyone, not sure if I'm doing this correctly, but I tried installing USD on Big Sur.
Im running into a Python crash when I try to run usdview.

----------------------- 'Python' is dying ------------------------
Python crashed. FATAL ERROR: Failed axiom: ' Py_IsInitialized() '
in operator() at line 148 of /Users/Aaron/Documents/Conda/USD/pxr/base/lib/tf/pyTracing.cpp

Steps to Reproduce

I'm building this with Conda:

  1. conda create -n USDenv python=3.7.7
  2. conda activate USDenv
  3. git clone https://github.com/PixarAnimationStudios/USD.git
  4. pip install jinja2 PySide2 PyOpenGL
  5. ...
  6. python USD/build_scripts/build_usd.py /opt/local/USD
  7. usdview /Users/aaron/Conda/USD/extras/usd/tutorials/convertingLayerFormats/Sphere.usda

System Information (OS, Hardware)

Big Sur 11.5.1

Package Versions

  • Python 3.7
  • Latest jinja2, Pyside2, PyOpenGL

Build Flags

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

@jilliene
Copy link

Filed as internal issue #USD-6898

@sunyab
Copy link
Contributor

sunyab commented Sep 20, 2021

Hi @aaronn, I don't have a conda environment set up so I'm unable to reproduce this locally. We've seen this issue in the past when USD is built against a Python library that is different from the one used by the python interpreter. You could try looking in your /opt/local/USD/build/USD/CMakeCache.txt file and see what the build is using for PYTHON_LIBRARY.

@toloudis
Copy link

toloudis commented Sep 21, 2021

I have the same error in a Python 3.8 anaconda environment.
My CMakeCache appears to show the expected python from my virtual env. I also see a Boost_PYTHON38_LIBRARY set to a file from the boost distro. Not sure whether these two could be in conflict, or if that is a red herring.

(usd) % grep PYTHON /usr/local/opt/USD/build/USD/CMakeCache.txt
Boost_PYTHON38_LIBRARY_DEBUG:FILEPATH=/usr/local/opt/USD/lib/libboost_python38.dylib
Boost_PYTHON38_LIBRARY_RELEASE:FILEPATH=/usr/local/opt/USD/lib/libboost_python38.dylib
PXR_ENABLE_PYTHON_SUPPORT:BOOL=ON
PXR_PYTHON_SHEBANG:STRING=/Users/danielt/opt/anaconda3/envs/usd/bin/python
PXR_USE_PYTHON_3:BOOL=ON
PYTHON_EXECUTABLE:FILEPATH=/Users/danielt/opt/anaconda3/envs/usd/bin/python
PYTHON_INCLUDE_DIR:PATH=/Users/danielt/opt/anaconda3/envs/usd/include/python3.8
PYTHON_LIBRARY:FILEPATH=/Users/danielt/opt/anaconda3/envs/usd/lib/libpython3.8.dylib
PYTHON_LIBRARY_DEBUG:FILEPATH=PYTHON_LIBRARY_DEBUG-NOTFOUND
//ADVANCED property for variable: Boost_PYTHON38_LIBRARY_DEBUG
Boost_PYTHON38_LIBRARY_DEBUG-ADVANCED:INTERNAL=1
//ADVANCED property for variable: Boost_PYTHON38_LIBRARY_RELEASE
Boost_PYTHON38_LIBRARY_RELEASE-ADVANCED:INTERNAL=1
//ADVANCED property for variable: PYTHON_EXECUTABLE
PYTHON_EXECUTABLE-ADVANCED:INTERNAL=1
//ADVANCED property for variable: PYTHON_INCLUDE_DIR
PYTHON_INCLUDE_DIR-ADVANCED:INTERNAL=1
//ADVANCED property for variable: PYTHON_LIBRARY
PYTHON_LIBRARY-ADVANCED:INTERNAL=1
//ADVANCED property for variable: PYTHON_LIBRARY_DEBUG
PYTHON_LIBRARY_DEBUG-ADVANCED:INTERNAL=1

and also:

(usd) % otool -L /usr/local/opt/USD/lib/python/pxr/USD/_usd.so | grep ython
/usr/local/opt/USD/lib/python/pxr/USD/_usd.so:
	@rpath/libpython3.8.dylib (compatibility version 3.8.0, current version 3.8.0)
	@rpath/libboost_python38.dylib (compatibility version 0.0.0, current version 0.0.0)

@mhamid3d
Copy link

@aaronn @toloudis I'm running into the same issue, has there been a solution found for this?

I'm running a conda environment with python 3.7, I checked every library linked with python and they're all correct. Even displaying all DYLIB's used when running usdview, all the paths are pointing to the correct python installation from conda.

Not sure what else to do, the conda environment is really important to the pipeline, and is used on Windows & Linux without problems.

@spitzak
Copy link

spitzak commented Dec 20, 2021

See issue #1466, and quite a few others.
It looked to me that it is relying on Python being initalized by a TF_REGISTRY_FUNCTION and there can in fact be zero of these. It was being triggered by IncRefCount which requires the Python runtime to be working.

@mhamid3d
Copy link

I found the cause of the issue for Conda + MacOS users:

Conda ships with a python 3 binary that is statically linked to the python library (which USD advises against in the doc). And the crash is likely caused by duplicate symbol errors since the python lib is trying to load twice. Although oddly this is only an issue on MacOS.

According to the BUILDING.md doc, there is a flag here to pass while building this will prevent static linking with the python library.

-DPXR_PY_UNDEFINED_DYNAMIC_LOOKUP=ON

I've just tested a build with this flag, and everything works as expected now!

@Bersaelor
Copy link

Bersaelor commented Jan 12, 2022

I also encountered this crash when building the pxr 21.11 release on MacOS Monterey. We were discussing the build in this issue case as we tried building on M1 Mac, but only managed to build when running in a Rosetta x86 environment.

In my case I build the USD using:

sudo python USD-21.11/build_scripts/build_usd.py --build-args TBB,extra_inc=big_iron.inc --python --no-imaging --no-docs --no-usdview --build-monolithic   /usr/local/USD

and got the crash:

------------------------------ Python terminated -------------------------------
Python crashed. FATAL ERROR: Failed axiom: ' Py_IsInitialized() '
in operator() at line 148 of /Users/konradfeiler/temp/USD-21.11/pxr/base/tf/pyTracing.cpp

The apple scripts are all written in Python 2, so before running the above I used pyenv to install 2.7.18 maybe that has something to do with it?

@mzvast
Copy link

mzvast commented Jul 15, 2022

macOS12.4 intel x64 crashes as well.
Hours wasted ~ I hate python.

pixar-oss pushed a commit that referenced this issue Feb 16, 2023
PXR_PY_UNDEFINED_DYNAMIC_LOOKUP might be explicitly set when
packaging wheels, or when cross compiling to a Python environment
that is not the current interpreter environment.
If it was not explicitly set to ON or OFF, then determine whether
Python was statically linked to its runtime library by fetching the
sysconfig variable LDLIBRARY, and set the variable accordingly.
If the variable does not exist, PXR_PY_UNDEFINED_DYNAMIC_LOOKUP will
default to OFF. On Windows, LDLIBRARY does not exist, as the default
will always be OFF.

Fixes #1620

(Internal change: 2263328)
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

8 participants