Forum Navigation
You need to log in to create posts and topics.

PYTHONPATH issue while using bin/ovitos on remote machine (CentOS)

Dear all,

I was having the following issue to open bin/ovitos when I am on our cluster running CentOS:

[yfwang09@mc2 ~]$ soft/ovito-3.0.0-dev539-x86-64/bin/ovitosTraceback (most recent call last):
File "/opt/ohpc/pub/compiler/intelpython3/lib/python3.6/site-packages/numpy/core/__init__.py", line 16, in <module>
from . import multiarray
ImportError: cannot import name 'multiarray' from 'numpy.core' (/opt/ohpc/pub/compiler/intelpython3/lib/python3.6/site-packages/numpy/core/__init__.py)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/home/yfwang09/soft/ovito-3.0.0-dev539-x86_64/bin/../lib/ovito/plugins/python/ovito/__init__.py", line 21, in <module>
import ovito.data
File "/home/yfwang09/soft/ovito-3.0.0-dev539-x86_64/bin/../lib/ovito/plugins/python/ovito/data/__init__.py", line 39, in <module>
import numpy as np
File "/opt/ohpc/pub/compiler/intelpython3/lib/python3.6/site-packages/numpy/__init__.py", line 158, in <module>
from . import add_newdocs
File "/opt/ohpc/pub/compiler/intelpython3/lib/python3.6/site-packages/numpy/add_newdocs.py", line 13, in <module>
from numpy.lib import add_newdoc
File "/opt/ohpc/pub/compiler/intelpython3/lib/python3.6/site-packages/numpy/lib/__init__.py", line 8, in <module>
from .type_check import *
File "/opt/ohpc/pub/compiler/intelpython3/lib/python3.6/site-packages/numpy/lib/type_check.py", line 11, in <module>
import numpy.core.numeric as _nx
File "/opt/ohpc/pub/compiler/intelpython3/lib/python3.6/site-packages/numpy/core/__init__.py", line 26, in <module>
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.

Original error was: cannot import name 'multiarray' from 'numpy.core' (/opt/ohpc/pub/compiler/intelpython3/lib/python3.6/site-packages/numpy/core/__init__.py)

ERROR: The Python script has exited with an error.
ERROR: Error during Python script execution.

It seems that ovitos is trying to load numpy from the local python site-packages while initializing. Then I tried to add the ovitos site-package path to PYTHONPATH:

export PYTHONPATH=$HOME/soft/ovito-3.0.0-dev503-x86_64/lib/python3.7/site-packages:$PYTHONPATH

Then ovitos runs correctly but my python3 could not load numpy anymore. How could I fix this problem?

Yes, it looks like 'ovitos' is picking up the search path you have specified in the system-wide PYTHONPATH environment variable. Your system's numpy library then get loaded instead of ovitos' own version of the library, which doesn't work, because they are not compatible with the ovitos interpreter (one is Python 3.6, the other is Python 3.7).

My suggestion is to temporarily clear the PYTHONPATH variable when running the ovitos interpreter. You can do this by prepending "PYTHONPATH=" to the command line:

PYTHONPATH= ./bin/ovitos yourscript.py

By avoiding the export statement, you can preserve the original system-wide value of PYTHONPATH and python3 should continue to work.

This works. Thanks Alex!