Discussion:
[otb-users] Beginner question: Import Error for Python3
'Zehui Ji' via otb-users
2018-06-23 14:48:08 UTC
Permalink
Hi,


I just begin using OTB and may have some silly questions. I am using MacOS High Sierra version10.13.5 (17F77).


After I downloaded OTB-6.4.0-Darwin64.run and extracted it following instructions from OTB cookbook. I first got this error:


*****Error occurred during installation******
OTB python bindings requires python2.6 or python2.7 but current detected python version is 3.6.4
If you have python2.6 or Python2.7 installed in your system
You should set OTB_PYTHON_EXE and re-run this installation script.
eg: OTB_PYTHON_EXE=/path/to/python2.7 ./OTB-X.Y-Linux64.run


Then, I found a solution post in this group:

https://groups.google.com/forum/#!topic/otb-users/4XvK-29nE4o

"

Hi Alexander,

When editing otbenv you need to set the path to the right bindings.
Do not mind the error as it will always occur if you are not using Python 2.
In short you should have :
PYTHONPATH=/Users/myuseraccount/anaconda3/python.app/Contents/MacOS/python:/path/to/OTB/lib/python3/ (path to python executable then path to bindings)
Then you will be able to import OTB in your Python code.
Hope this will work.

Antoine

"


I followed the solution and modified the otbenv.profile to bind OTB to python3. Then I added all paths in otbenv.profile to ~/.bash_profile and restart my mac.

Here, I thought I have finished the installation. So, I tried to write some python code in jupyter notebook to test. However, when I run the import otbApplication, it poped up an error as following:


ImportError: dlopen(/Users/jibusi/OTB-6.6.0-Darwin64/lib/python3/_otbApplication.so, 2): Library not loaded: /Library/Frameworks/Python.framework/Versions/3.5/Python
Referenced from: /Users/jibusi/OTB-6.6.0-Darwin64/lib/python3/_otbApplication.so
Reason: image not found


I thought it may be because I didn't install python3.5 in my mac. So, I install python3.5 via https://www.python.org/downloads/release/python-350/. But when I tried to run again, the kernel just died. I have no ideas.


Can someone help me out? I have spent half a day to install it.


Thanks.
--
--
Check the OTB FAQ at
http://www.orfeo-toolbox.org/FAQ.html

You received this message because you are subscribed to the Google
Groups "otb-users" group.
To post to this group, send email to otb-***@googlegroups.com
To unsubscribe from this group, send email to
otb-users+***@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/otb-users?hl=en
---
You received this message because you are subscribed to the Google Groups "otb-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to otb-users+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Zehui Ji
2018-06-24 02:24:00 UTC
Permalink
Also kernel return an error:

Python 3.6.4 |Anaconda custom (x86_64)| (default, Jan 16 2018, 12:04:33)

[GCC 4.2.1 Compatible Clang 4.0.1 (tags/RELEASE_401/final)] on darwin

Type "help", "copyright", "credits" or "license" for more information.
Post by 'Zehui Ji' via otb-users
import otbApplication
Fatal Python error: PyThreadState_Get: no current thread

Segmentation fault: 11

Does anyone know how to fix this issue?

Thanks.
--
--
Check the OTB FAQ at
http://www.orfeo-toolbox.org/FAQ.html

You received this message because you are subscribed to the Google
Groups "otb-users" group.
To post to this group, send email to otb-***@googlegroups.com
To unsubscribe from this group, send email to
otb-users+***@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/otb-users?hl=en
---
You received this message because you are subscribed to the Google Groups "otb-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to otb-users+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Guillaume Pasero
2018-06-25 07:14:17 UTC
Permalink
Zehui Ji
2018-06-25 08:25:49 UTC
Permalink
Hi Guillaume,

Thank you for your reply.

I have noticed the possible solution you just mentioned. So, I tried to
change to use python2.7.

(I have installed three different versions of python (2.7, 3.5, 3.6) and
also virtual envs by conda in my mac.)

First, I set PYTHONPATH to python 2.7 and install numpy packages to
python2.7:

For python2.7:
PYTHONPATH="/Library/Frameworks/Python.framework/Versions/2.7/bin/python:/Users/jibusi/OTB-6.6.0-Darwin64/lib/python:${PYTHONPATH}"


Then, I tested it. But results are the same (kernels have a fatal error).

For python2.7

Python 2.7.10 (v2.7.10:15c95b7d81dc, May 23 2015, 09:33:12)

[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin

Type "help", "copyright", "credits" or "license" for more information.
Post by 'Zehui Ji' via otb-users
import otbApplication
Fatal Python error: PyThreadState_Get: no current thread

Abort trap: 6

I even create a new user in my mac which only installed python2.7, but the
error occurs again.

Could you please help me out? I have spent two days in this.

Cheers,
Z
Hi,
From your error message, it looks like you are still using Python 3.6.4.
Maybe you just need to launch Python from a 3.5 interpreter.
Regards,
Guillaume
Python 3.6.4 |Anaconda custom (x86_64)| (default, Jan 16 2018, 12:04:33)
[GCC 4.2.1 Compatible Clang 4.0.1 (tags/RELEASE_401/final)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
Post by 'Zehui Ji' via otb-users
Post by 'Zehui Ji' via otb-users
import otbApplication
Fatal Python error: PyThreadState_Get: no current thread
Segmentation fault: 11
Does anyone know how to fix this issue?
Thanks.
--
--
Check the OTB FAQ at
http://www.orfeo-toolbox.org/FAQ.html
You received this message because you are subscribed to the Google
Groups "otb-users" group.
<javascript:>
To unsubscribe from this group, send email to
For more options, visit this group at
http://groups.google.com/group/otb-users?hl=en
---
You received this message because you are subscribed to the Google Groups
"otb-users" group.
To unsubscribe from this group and stop receiving emails from it, send an
For more options, visit https://groups.google.com/d/optout.
--
<http://www.c-s.fr> *Guillaume PASERO*
Responsable technique
*Business Unit ESPACE & GeoInformation - Département Payload Data &
Applications*
*CS SystÚmes d'Information*
Parc de la Grande Plaine - 5, Rue Brindejonc des Moulinais - BP 15872
31506 Toulouse Cedex 05 - FRANCE
--
--
Check the OTB FAQ at
http://www.orfeo-toolbox.org/FAQ.html

You received this message because you are subscribed to the Google
Groups "otb-users" group.
To post to this group, send email to otb-***@googlegroups.com
To unsubscribe from this group, send email to
otb-users+***@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/otb-users?hl=en
---
You received this message because you are subscribed to the Google Groups "otb-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to otb-users+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Guillaume Pasero
2018-06-25 09:19:08 UTC
Permalink
Zehui Ji
2018-06-25 09:30:04 UTC
Permalink
Hi Guillaume,

Thank you for your time answering my question.

I run your command and get:

dyn-118-139-70-252:~ jibusi$ otool -l
/Users/jibusi/OTB-6.6.0-Darwin64/lib/python/_otbApplication.so | grep -A 3
'LC_RPATH'

cmd LC_RPATH

cmdsize 56

path /Users/jibusi/OTB-6.6.0-Darwin64/lib (offset 12)

Also I have tried the self tester before. It always fails at python
wrapping.

dyn-118-139-70-252:~ jibusi$ sh
/Users/jibusi/OTB-6.6.0-Darwin64/tools/selftester.sh

CUR_DIR=/Users/jibusi/OTB-6.6.0-Darwin64

Check 1/4 : PASS

ERROR: python wrapping test failed :

EXIT_ON_ERROR=1

I have no idea how to fix it. Hope you could help me out.

Regrads,
Z
Can you try to run the following command ? What do you get ?
otool -l /Users/jibusi/OTB-6.6.0-Darwin64/lib/python/_otbApplication.so |
grep -A 3 'LC_RPATH'
You also have a self tester script that you can run : /
Users/jibusi/OTB-6.6.0-Darwin64/tools/selftester.sh
Regards,
Guillaume
Hi Guillaume,
Thank you for your reply.
I have noticed the possible solution you just mentioned. So, I tried to
change to use python2.7.
(I have installed three different versions of python (2.7, 3.5, 3.6) and
also virtual envs by conda in my mac.)
First, I set PYTHONPATH to python 2.7 and install numpy packages to
PYTHONPATH="/Library/Frameworks/Python.framework/Versions/2.7/bin/python:/Users/jibusi/OTB-6.6.0-Darwin64/lib/python:${PYTHONPATH}"
Then, I tested it. But results are the same (kernels have a fatal error).
For python2.7
Python 2.7.10 (v2.7.10:15c95b7d81dc, May 23 2015, 09:33:12)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
Post by 'Zehui Ji' via otb-users
import otbApplication
Fatal Python error: PyThreadState_Get: no current thread
Abort trap: 6
I even create a new user in my mac which only installed python2.7, but the
error occurs again.
Could you please help me out? I have spent two days in this.
Cheers,
Z
Hi,
From your error message, it looks like you are still using Python 3.6.4.
Maybe you just need to launch Python from a 3.5 interpreter.
Regards,
Guillaume
Python 3.6.4 |Anaconda custom (x86_64)| (default, Jan 16 2018, 12:04:33)
[GCC 4.2.1 Compatible Clang 4.0.1 (tags/RELEASE_401/final)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
Post by 'Zehui Ji' via otb-users
Post by 'Zehui Ji' via otb-users
import otbApplication
Fatal Python error: PyThreadState_Get: no current thread
Segmentation fault: 11
Does anyone know how to fix this issue?
Thanks.
--
--
Check the OTB FAQ at
http://www.orfeo-toolbox.org/FAQ.html
You received this message because you are subscribed to the Google
Groups "otb-users" group.
To unsubscribe from this group, send email to
For more options, visit this group at
http://groups.google.com/group/otb-users?hl=en
---
You received this message because you are subscribed to the Google Groups
"otb-users" group.
To unsubscribe from this group and stop receiving emails from it, send an
For more options, visit https://groups.google.com/d/optout.
--
<http://www.c-s.fr> *Guillaume PASERO*
Responsable technique
*Business Unit ESPACE & GeoInformation - Département Payload Data &
Applications*
*CS SystÚmes d'Information*
Parc de la Grande Plaine - 5, Rue Brindejonc des Moulinais - BP 15872
31506 Toulouse Cedex 05 - FRANCE
--
--
Check the OTB FAQ at
http://www.orfeo-toolbox.org/FAQ.html
You received this message because you are subscribed to the Google
Groups "otb-users" group.
<javascript:>
To unsubscribe from this group, send email to
For more options, visit this group at
http://groups.google.com/group/otb-users?hl=en
---
You received this message because you are subscribed to the Google Groups
"otb-users" group.
To unsubscribe from this group and stop receiving emails from it, send an
For more options, visit https://groups.google.com/d/optout.
--
<http://www.c-s.fr> *Guillaume PASERO*
Responsable technique
*Business Unit ESPACE & GeoInformation - Département Payload Data &
Applications*
*CS SystÚmes d'Information*
Parc de la Grande Plaine - 5, Rue Brindejonc des Moulinais - BP 15872
31506 Toulouse Cedex 05 - FRANCE
--
--
Check the OTB FAQ at
http://www.orfeo-toolbox.org/FAQ.html

You received this message because you are subscribed to the Google
Groups "otb-users" group.
To post to this group, send email to otb-***@googlegroups.com
To unsubscribe from this group, send email to
otb-users+***@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/otb-users?hl=en
---
You received this message because you are subscribed to the Google Groups "otb-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to otb-users+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Guillaume Pasero
2018-06-27 06:59:43 UTC
Permalink
Loading...