nrn icon indicating copy to clipboard operation
nrn copied to clipboard

Intel compiler on Mac, problem with PYTHONHOME

Open nrnhines opened this issue 5 years ago • 2 comments

Pull request #608 left off with a comment about building with

cmake .. -DNRN_ENABLE_INTERVIEWS=OFF -DCMAKE_INSTALL_PREFIX=install -DPYTHON_EXECUTABLE=/opt/intel/intelpython3/bin/python3.7 -DCMAKE_C_COMPILER=icc -DCMAKE_CXX_COMPILER=icpc -DNRN_ENABLE_PYTHON_DYNAMIC=ON
make -j install

but I need to debug

unset PYTHONHOME
unset NRN_PYLIB
$ nrniv -python -pyexe /opt/intel/intelpython3/bin/python3.7
NEURON -- VERSION 8.0.dev-126-gdb89341a pramodk/osx-intel (db89341a) 2020-06-24
Duke, Yale, and the BlueBrain Project -- Copyright 1984-2019
See http://neuron.yale.edu/neuron/credits

Could not find platform independent libraries <prefix>
Could not find platform dependent libraries <exec_prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
Fatal Python error: initfsencoding: unable to load the file system codec
ModuleNotFoundError: No module named 'encodings'

For dynamic python loading this is resolved with pull request #617 but there remain two issues with -DNRN_ENABLE_PYTHON_DYNAMIC=OFF

First, when launching nrniv one needs an explicit PYTHONHOME

export PYTHONHOME="/opt/intel/intelpython3"
$ nrniv -python
NEURON -- VERSION 8.0.dev-124-g2c0a97a8 nrnpy-pyhome (2c0a97a8) 2020-06-27
Duke, Yale, and the BlueBrain Project -- Copyright 1984-2019
See http://neuron.yale.edu/neuron/credits

>>> from neuron import h
>>> ^D
$unset PYTHONHOME
$ nrniv -python
NEURON -- VERSION 8.0.dev-124-g2c0a97a8 nrnpy-pyhome (2c0a97a8) 2020-06-27
Duke, Yale, and the BlueBrain Project -- Copyright 1984-2019
See http://neuron.yale.edu/neuron/credits

Could not find platform independent libraries <prefix>
Could not find platform dependent libraries <exec_prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
Fatal Python error: initfsencoding: unable to load the file system codec
ModuleNotFoundError: No module named 'encodings'

Current thread 0x000000010ee28dc0 (most recent call first):
Abort trap: 6

That is not a huge problem. Much worse is launching

$ /opt/intel/intelpython3/bin/python3.7
Python 3.7.7 (default, Mar 13 2020, 09:43:04) 
[Clang 4.0.1 (tags/RELEASE_401/final)] :: Intel(R) Corporation on darwin
Type "help", "copyright", "credits" or "license" for more information.
Intel(R) Distribution for Python is brought to you by Intel Corporation.
Please check out: https://software.intel.com/en-us/python-distibution
>>> from neuron import h
Fatal Python error: PyMUTEX_LOCK(_PyRuntime.ceval.gil.mutex) failed

Abort trap: 6

Perhaps some hints that can help are

$ otool -l install/bin/nrniv|grep -A 3 LC_RPATH | grep path
         path /Users/michaelhines/neuron/nrnicc/build/install/lib (offset 12)
         path /opt/intel/intelpython3/lib (offset 12)

$ otool -l /opt/intel/intelpython3/bin/python3.7 |grep -A 3 LC_RPATH | grep path
         path /localdisk/tc/agent2/work/77d6987f4a2d253e/conda-build/python_1584108639102/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_pl/lib (offset 12)
         path /localdisk/tc/agent2/work/77d6987f4a2d253e/conda-build/python_1584108639102/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_pl/lib (offset 12)
         path @loader_path/../lib/ (offset 12)

$ otool -l install/lib/python/neuron/hoc.cpython-37m-darwin.so |grep -A 3 LC_RPATH | grep path
         path @loader_path/../../ (offset 12)
         path /../lib (offset 12)

nrnhines avatar Jun 28 '20 17:06 nrnhines

I would like to share the output I get. In my case I installed python through Anaconda.

Python 3.8.8 (default, Apr 13 2021, 12:59:45) 
[Clang 10.0.0 ] :: Anaconda, Inc. on darwin

>>> import neuron
Fatal Python error: PyMUTEX_LOCK(gil->mutex) failed
Python runtime state: unknown

Abort trap: 6

nico-canta avatar Aug 31 '21 09:08 nico-canta

@alexsavulescu : I think this is worth adding to our next release milestone. I thought this is only with Intel Python but now reproducible with Anaconda python on MacOS as well.

pramodk avatar Aug 31 '21 10:08 pramodk