Hello to the list,
we just bought Trelis and have some issues with Python:
I want to use numpy and h5py (Linux)
According to sys.version Trelis comes with Python 2.7.3.
I tried to link numpy and h5py from my /usr/lib64/python2.7/site-packages to
/opt/Trelis-16.3/bin/lib/python2.7/site-packages
Then
import numpy
Fails with an multiarray issue which seems to be caused by incompatible versions.
My local python2 is Python 2.7.13
I asked someone who is using Trelis with numpy and h5py about his numpy installation.
When I copy it to
/opt/Trelis-16.3/bin/lib/python2.7/site-packages/
I get
[code]import numpy
…
from . import multiarray
ImportError: /opt/Trelis-16.3/bin/lib/python2.7/site-packages/numpy/core/multiarray.so: undefined symbol: _PyUnicodeUCS4_IsWhitespace
[/quote]
The same error occured on another Linux system (Ubuntu, I use openSUSE)
What can I do?
I see the following options:
make Trelis to use my System Python 2.7
compile Python 2.7.3 manually and then build numpy manually. However this failed in the first attempt. And when I build Paraview 5.3 with Python I also have this Unicode issue.
I put more work on the issue. I could life without h5py by adapting a python mesh exporter we already have, however it would be very annoying to have to life without numpy.
Numpy is build via python, so I assume I have to build numpy with a python 2.7.3 interpreter.
I really could not find a python interpreter binary in the Trelis distribution (Linux rpm) I could use manually.
I failed to build python 2.7.3 locally. build and install works but when I execute the binary I get
./python
Could not find platform dependent libraries <exec_prefix>
Consider setting $PYTHONHOME to [:<exec_prefix>]
Traceback (most recent call last):
File “/home/fwein/tmp/lib/python2.7/site.py”, line 563, in
main()
File “/home/fwein/tmp/lib/python2.7/site.py”, line 545, in main
known_paths = addusersitepackages(known_paths)
File “/home/fwein/tmp/lib/python2.7/site.py”, line 278, in addusersitepackages
user_site = getusersitepackages()
File “/home/fwein/tmp/lib/python2.7/site.py”, line 253, in getusersitepackages
user_base = getuserbase() # this will also set USER_BASE
File “/home/fwein/tmp/lib/python2.7/site.py”, line 243, in getuserbase
USER_BASE = get_config_var(‘userbase’)
File “/home/fwein/tmp/lib/python2.7/sysconfig.py”, line 521, in get_config_var
return get_config_vars().get(name)
File “/home/fwein/tmp/lib/python2.7/sysconfig.py”, line 420, in get_config_vars
_init_posix(_CONFIG_VARS)
File “/home/fwein/tmp/lib/python2.7/sysconfig.py”, line 288, in _init_posix
raise IOError(msg)
IOError: invalid Python installation: unable to open /home/fwein/tmp/lib/python2.7/config/Makefile (No such file or directory)
But even building numpy with my local python failed for me.
Is there any change that Trelis simply extends its Python to numpy? That would really be the best! :))
Based on the error, I suspect that our version of Python and your version of Python were built using different versions of Unicode. Here is one way to check in Python 2.7 which version of Unicode it was built with:
Also, from the Python docs (docs.python.org/2/c-api/unicode.html) it says “Note that UCS2 and UCS4 Python builds are not binary compatible”, which would explain why you can’t import numpy into our Python.
We are reviewing the license for numpy for possibly adding it to our package.
There are two issues: When I link /usr/lib64/python2.7/site-packages/numpy
for my Python 2.7.13 I get the error
import numpy
Traceback (most recent call last):
File “”, line 1, in
File “/opt/Trelis-16.3/bin/lib/python2.7/site-packages/numpy/init.py”, line 142, in
from . import add_newdocs
File “/opt/Trelis-16.3/bin/lib/python2.7/site-packages/numpy/add_newdocs.py”, line 13, in
from numpy.lib import add_newdoc
File “/opt/Trelis-16.3/bin/lib/python2.7/site-packages/numpy/lib/init.py”, line 8, in
from .type_check import *
File “/opt/Trelis-16.3/bin/lib/python2.7/site-packages/numpy/lib/type_check.py”, line 11, in
import numpy.core.numeric as _nx
File “/opt/Trelis-16.3/bin/lib/python2.7/site-packages/numpy/core/init.py”, line 24, in
raise ImportError(msg)
ImportError:
Importing the multiarray numpy extension module failed. Most
likely you are trying to import a failed build of numpy.
If you’re working with a numpy git repo, try git clean -xdf (removes all
files not under version control). Otherwise reinstall numpy.
As as I understand this is because Trelis’ Python is too old.
print(sys.version)
2.7.3 (default, Dec 6 2012, 13:01:46)
[GCC 4.1.3 20080704 (prerelease) (Debian 4.1.2-25)]
But you are right, even with equal version I would have been bitten by the unicode (thanks for the link!)
Trelis: print(sys.maxunicode) -> 65535
my system: print(sys.maxunicode) -> 1114111
Whyever 2^16 is not enough and one wants more???
So adding numpy with Trelis would be really nice. BTW, Paraview adds numpy.
I did an experiment and removed python from my Trelis installation so that it would fall back to the system python. That is, I removed bin/libpython* and bin/lib/. With that change, Trelis starts up fine, which tells me that Trelis is not sensitive to the ucs2 vs. ucs4 difference.
I tried alternatives to force Trelis to use the system python, without modifying the Trelis installation, but ran into difficulty with that. I assume its because of something we do which sets PYTHONHOME and other things.
It looks like we will add numpy to Trelis. Thanks for your comments.
From what I understand, having no python by itself is the situation for the macOS version and it indeed works fine there (import numpy and import h5py without issues).