MDSplus / mdsplus

The MDSplus data management system
https://mdsplus.org/
Other
74 stars 44 forks source link

Error finding library: Mdsdcl on new installation #1464

Closed jhillairet closed 5 years ago

jhillairet commented 5 years ago

Hello,

I have a anaconda (conda 4.3.11) Python 2 distribution (2.7.13 64bits), in which I wanted to install the latest version of MDSplus python binding.

I've cloned the git repository, and installed the python package into my conda environment as : pip install ~/mdsplus/mdsobjects/python. Installation works, at least seems to:

Processing /Home/JH218595/mdsplus/mdsobjects/python
Building wheels for collected packages: mdsplus-unknown
  Running setup.py bdist_wheel for mdsplus-unknown ... done
  Stored in directory: /tmp/pip-ephem-wheel-cache-7EgChX/wheels/45/24/18/899f2f86dbecb57f5fada081930808255a6846692e42945ebb
Successfully built mdsplus-unknown
Installing collected packages: mdsplus-unknown
  Found existing installation: mdsplus-unknown 1.0.0
    Uninstalling mdsplus-unknown-1.0.0:
      Successfully uninstalled mdsplus-unknown-1.0.0
Successfully installed mdsplus-unknown-1.0.0

however, starting python and importing MDSplus leads to the following error:

Python 2.7.13 |Anaconda custom (64-bit)| (default, Dec 20 2016, 23:09:15) 
Type "copyright", "credits" or "license" for more information.

IPython 5.3.0 -- An enhanced Interactive Python.
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python's own help system.
object?   -> Details about 'object', use 'object??' for extra details.

In [1]: import MDSplus
Issues loading Mdsdcl, trying find_library
Issues loading Mdsdcl, trying find_library
Issues loading Mdsdcl, trying find_library
Issues loading Mdsdcl, trying find_library
Issues loading Mdsdcl, trying find_library
Issues loading Mdsdcl, trying find_library
Issues loading Mdsdcl, trying find_library
Issues loading Mdsdcl, trying find_library
Issues loading Mdsdcl, trying find_library
Issues loading Mdsdcl, trying find_library
Issues loading Mdsdcl, trying find_library
Issues loading Mdsdcl, trying find_library
Issues loading Mdsdcl, trying find_library
Issues loading Mdsdcl, trying find_library
Issues loading Mdsdcl, trying find_library
Issues loading Mdsdcl, trying find_library
---------------------------------------------------------------------------
Exception                                 Traceback (most recent call last)
<ipython-input-1-7b7072d8ab46> in <module>()
----> 1 import MDSplus

/Home/JH218595/anaconda2/envs/piScope_matplotlib2/lib/python2.7/site-packages/MDSplus/__init__.py in <module>()
     84 
     85 if __name__==__package__:
---> 86     load()
     87     def getPyLib():
     88         from ctypes.util import find_library

/Home/JH218595/anaconda2/envs/piScope_matplotlib2/lib/python2.7/site-packages/MDSplus/__init__.py in load(gbls)
     80                 'apd','event','tree','scope','_mdsshr',
     81                 'connection','mdsdcl','mdsExceptions'):
---> 82         loadmod_full(mod,gbls)
     83     return gbls
     84 

/Home/JH218595/anaconda2/envs/piScope_matplotlib2/lib/python2.7/site-packages/MDSplus/__init__.py in loadmod_full(name, gbls)
     73 def load(gbls=globals()):
     74     def loadmod_full(name,gbls):
---> 75         mod=_mimport(name)
     76         for key in mod.__dict__:
     77             if not key.startswith('_'):

/Home/JH218595/anaconda2/envs/piScope_matplotlib2/lib/python2.7/site-packages/MDSplus/__init__.py in _mimport(name, level)
     42         return __import__(name, globals(), level=level)
     43     except:
---> 44         return __import__(name, globals())
     45 try:
     46     @property

/Home/JH218595/anaconda2/envs/piScope_matplotlib2/lib/python2.7/site-packages/MDSplus/mdsdata.py in <module>()
    784 _dsc.dtypeToClass[EmptyData.dtype_id]=EmptyData
    785 
--> 786 _cmp=_mimport('compound')
    787 _scr=_mimport('mdsscalar')
    788 _arr=_mimport('mdsarray')

/Home/JH218595/anaconda2/envs/piScope_matplotlib2/lib/python2.7/site-packages/MDSplus/mdsdata.py in _mimport(name, level)
     28         return __import__(name, globals(), level=level)
     29     except:
---> 30         return __import__(name, globals())
     31 
     32 import numpy as _N, ctypes as _C

/Home/JH218595/anaconda2/envs/piScope_matplotlib2/lib/python2.7/site-packages/MDSplus/compound.py in <module>()
     36 _dsc=_mimport('descriptor')
     37 _dat=_mimport('mdsdata')
---> 38 _tre=_mimport('tree')
     39 _exc=_mimport('mdsExceptions')
     40 

/Home/JH218595/anaconda2/envs/piScope_matplotlib2/lib/python2.7/site-packages/MDSplus/compound.py in _mimport(name, level)
     28         return __import__(name, globals(), level=level)
     29     except:
---> 30         return __import__(name, globals())
     31 
     32 import ctypes as _C

/Home/JH218595/anaconda2/envs/piScope_matplotlib2/lib/python2.7/site-packages/MDSplus/tree.py in <module>()
     42 _arr=_mimport('mdsarray')
     43 _scr=_mimport('mdsscalar')
---> 44 _dcl=_mimport('mdsdcl')
     45 _cmp=_mimport('compound')
     46 _dsc=_mimport('descriptor')

/Home/JH218595/anaconda2/envs/piScope_matplotlib2/lib/python2.7/site-packages/MDSplus/tree.py in _mimport(name, level)
     28         return __import__(name, globals(), level=level)
     29     except:
---> 30         return __import__(name, globals())
     31 import ctypes as _C
     32 import numpy as _N

/Home/JH218595/anaconda2/envs/piScope_matplotlib2/lib/python2.7/site-packages/MDSplus/mdsdcl.py in <module>()
     39 _tre=_mimport('tree')
     40 
---> 41 _mdsdcl=_ver.load_library('Mdsdcl')
     42 _mdsdcl_do_command_dsc=_mdsdcl.mdsdcl_do_command_dsc
     43 _mdsdcl_do_command_dsc.argtypes=[_C.c_char_p, _dsc.Descriptor_xd.PTR, _dsc.Descriptor_xd.PTR]

/Home/JH218595/anaconda2/envs/piScope_matplotlib2/lib/python2.7/site-packages/MDSplus/version.pyc in load_library(name)
     74     except: raise Exception("Could not find library: %s"%(name,))
     75     if libnam is None:
---> 76             raise Exception("Could not find library: %s"%(name,))
     77     try:   return C.CDLL(libnam)
     78     except:pass

Exception: Could not find library: Mdsdc

interestingly, the error is not the same when using python instead of ipython :

Python 2.7.13 |Anaconda custom (64-bit)| (default, Dec 20 2016, 23:09:15) 
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
Anaconda is brought to you by Continuum Analytics.
Please check out: http://continuum.io/thanks and https://anaconda.org
>>> import MDSplus
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Home/JH218595/anaconda2/envs/piScope_matplotlib2/lib/python2.7/site-packages/MDSplus/__init__.py", line 86, in <module>
    load()
  File "/Home/JH218595/anaconda2/envs/piScope_matplotlib2/lib/python2.7/site-packages/MDSplus/__init__.py", line 82, in load
    loadmod_full(mod,gbls)
  File "/Home/JH218595/anaconda2/envs/piScope_matplotlib2/lib/python2.7/site-packages/MDSplus/__init__.py", line 75, in loadmod_full
    mod=_mimport(name)
  File "/Home/JH218595/anaconda2/envs/piScope_matplotlib2/lib/python2.7/site-packages/MDSplus/__init__.py", line 44, in _mimport
    return __import__(name, globals())
  File "/Home/JH218595/anaconda2/envs/piScope_matplotlib2/lib/python2.7/site-packages/MDSplus/mdsdata.py", line 786, in <module>
    _cmp=_mimport('compound')
  File "/Home/JH218595/anaconda2/envs/piScope_matplotlib2/lib/python2.7/site-packages/MDSplus/mdsdata.py", line 30, in _mimport
    return __import__(name, globals())
  File "/Home/JH218595/anaconda2/envs/piScope_matplotlib2/lib/python2.7/site-packages/MDSplus/compound.py", line 38, in <module>
    _tre=_mimport('tree')
  File "/Home/JH218595/anaconda2/envs/piScope_matplotlib2/lib/python2.7/site-packages/MDSplus/compound.py", line 30, in _mimport
    return __import__(name, globals())
  File "/Home/JH218595/anaconda2/envs/piScope_matplotlib2/lib/python2.7/site-packages/MDSplus/tree.py", line 48, in <module>
    _con=_mimport('connection')
  File "/Home/JH218595/anaconda2/envs/piScope_matplotlib2/lib/python2.7/site-packages/MDSplus/tree.py", line 30, in _mimport
    return __import__(name, globals())
  File "/Home/JH218595/anaconda2/envs/piScope_matplotlib2/lib/python2.7/site-packages/MDSplus/connection.py", line 49, in <module>
    _GetAnswerInfoTO=__MdsIpShr.GetAnswerInfoTO
  File "/Home/JH218595/anaconda2/envs/piScope_matplotlib2/lib/python2.7/ctypes/__init__.py", line 375, in __getattr__
    func = self.__getitem__(name)
  File "/Home/JH218595/anaconda2/envs/piScope_matplotlib2/lib/python2.7/ctypes/__init__.py", line 380, in __getitem__
    func = self._FuncPtr((name_or_ordinal, self))
AttributeError: /usr/local/mdsplus/lib/libMdsIpShr.so: undefined symbol: GetAnswerInfoTO
>>> 

Do you any suggestion on how to solve that ?

tfredian commented 5 years ago

I suspect the problem is that you are installing the python module from the head of the git repository which is likely to be incompatible with the MDSplus libraries that you currently have installed on your system. You should instead use the python sources found in /usr/local/mdsplus/mdsobjects/python which should be compatible with the installed libaries:

$ pip install /usr/local/mdsplus/mdsobjects/python
jhillairet commented 5 years ago

OK, I understand. Seems by the way that python and ipython doesn't see the same path or environment variable...

My goal was however to use the latest MDSplus libraries, since the one installed on /usr/local is rather old. (The real reason behind is that I got some error from MDSplus when looking to the CEA mdsplus server, I just would like to see if it is still the same situation with latest MDSplus version...). How can I do that ?

tfredian commented 5 years ago

The best solution is to have the system manager update MDSplus on the system. The second best solution would be to try it on another system which has a more recent version of MDSplus installed. If you don't have either of those options then you will either need to attempt to build MDSplus from sources or manually download recent MDSplus installers from the MDSplus web site and try to install them to another directory or use tools to extract the contents of the installers and define environment variables to point to the libraries etc.

jwbrooks0 commented 5 years ago

Edit: Interesting, when I first came across this error, it was the mdsdcl error. When I regenerated the error to ask about it here, it changed to a mdsshr error, and I didn't notice. My apologies for the confusion below. Let me know if I should repost my error as a new issue or maybe it's related enough. Thanks.

Hello, I'm also having a very similar problem. As of today, I installed a fresh Ubuntu 18.04 build onto my laptop (wanted a clean upgrade from ubuntu 16), and I am getting (I think) the exact same mdsdcl error as jhillairet. To make sure none of the other programs/libraries/etc were causing the problem, I wiped my computer again and immediately reproduced the error with the following steps:

  1. $ sudo apt-get install python-pip
  2. Copied the latest alpha from github and extracted it
  3. $ cd ~/Downloads/mdsplus-alpha/mdsobjects/python
  4. $ pip install .
    Processing /home/john/Downloads/mdsplus-alpha/mdsobjects/python
    Installing collected packages: mdsplus
    Running setup.py install for mdsplus ... done
    Successfully installed mdsplus-1.0
  5. $ sudo apt-get install python-numpy
  6. $ python
    Python 2.7.15rc1 (default, Nov 12 2018, 14:31:15) 
    [GCC 7.3.0] on linux2
    Type "help", "copyright", "credits" or "license" for more information.
  7. >>> import MDSplus

and immediately get:

Issues loading MdsShr, trying find_library
Issues loading MdsShr, trying find_library
Issues loading MdsShr, trying find_library
Issues loading MdsShr, trying find_library
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/john/.local/lib/python2.7/site-packages/MDSplus/__init__.py", line 86, in <module>
    load()
  File "/home/john/.local/lib/python2.7/site-packages/MDSplus/__init__.py", line 82, in load
    loadmod_full(mod,gbls)
  File "/home/john/.local/lib/python2.7/site-packages/MDSplus/__init__.py", line 75, in loadmod_full
    mod=_mimport(name)
  File "/home/john/.local/lib/python2.7/site-packages/MDSplus/__init__.py", line 44, in _mimport
    return __import__(name, globals())
  File "/home/john/.local/lib/python2.7/site-packages/MDSplus/mdsdata.py", line 35, in <module>
    _dsc=_mimport('descriptor')
  File "/home/john/.local/lib/python2.7/site-packages/MDSplus/mdsdata.py", line 30, in _mimport
    return __import__(name, globals())
  File "/home/john/.local/lib/python2.7/site-packages/MDSplus/descriptor.py", line 39, in <module>
    _MdsShr=_ver.load_library('MdsShr')
  File "/home/john/.local/lib/python2.7/site-packages/MDSplus/version.py", line 76, in load_library
    raise Exception("Could not find library: %s"%(name,))
Exception: Could not find library: MdsShr'

As suggested here, I also tried editing sources.list, adding the key, updating, and $ sudo apt-get install mdsplus-python, but this resulted in the same error as above.

tfredian, to be honest, I'm not quite following your latest post.

Does anyone have any suggestions? Thank you.

tfredian commented 5 years ago

If you installed the mdsplus-python via apt-get I assume it installed several other mdsplus packages such as mdsplus-kernel, mdsplus-kernel-bin etc.. The required shared libraries should have been installed in /usr/local/mdsplus/lib64. Your post referred to some ~/Downloads/mdsplus-alpha/mdsobjects/python drectory which may be incompatible with the installed mdsplus. I don't know if you specified stable or alpha in your sources.list but in any event after installing the mdsplus-python package the matching python code should be in /usr/local/mdsplus/mdsobjects/python and that should be used with pip using 'pip install /usr/local/mdsplus/mdsobjects/python'. After doing the install you will need to log out and log back in to get the environment variables correct or just do: 'source /etc/profile' to get the needed environment variables.

zack-vii commented 5 years ago

can we close this issue: If kept open for future references, should we add a FAQ report under http://www.mdsplus.org/index.php?title=Documentation:FAQ In general should we consider this for other help_wanted tagged issues