Eigenstate / vmd-python

Installable VMD as a python module
Other
129 stars 24 forks source link

library issue on MacOS #5

Closed smsaladi closed 6 years ago

smsaladi commented 6 years ago

I seem to be having a library issue when installing this via pip on MacOS. Any thoughts here? Are others having issues of this sort?

It might be nice to add MacOS to the travis config to see if it installs properly on a clean build.

➜  ml-ecoli-svmrank git:(master) ✗ pip install -i https://pypi.anaconda.org/rbetz/simple vmd-python

Collecting vmd-python
  Downloading https://pypi.anaconda.org/rbetz/simple/vmd-python/2.0.1/vmd-python-2.0.1.tar.gz (27.8MB)
    100% |████████████████████████████████| 27.8MB 16kB/s
Building wheels for collected packages: vmd-python
  Running setup.py bdist_wheel for vmd-python ... error
  Complete output from command /Users/saladi/anaconda3/bin/python -u -c "import setuptools, tokenize;__file__='/private/var/folders/ds/85_stvb54l77t3ddk3vtb2d40000gn/T/pip-build-2liosvpe/vmd-python/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d /var/folders/ds/85_stvb54l77t3ddk3vtb2d40000gn/T/tmpqh9zpv55pip-wheel- --python-tag cp35:
  running bdist_wheel
  running build
  Compiling VMD
  Finding libraries...
  /bin/sh: ldconfig: command not found
  WARNING: Could not find library file 'libtcl8.5.so' in standard library directories.
   Defaulting to: '/Users/saladi/anaconda3/lib/libtcl8.5.so'
     LIB: libtcl8.5.so -> /Users/saladi/anaconda3/lib/libtcl8.5.so

  WARNING: Could not find include file 'tcl.h' in standard include directories.
   Defaulting to: '/Users/saladi/anaconda3/include/tcl.h'
     INC: tcl.h -> /Users/saladi/anaconda3/include/tcl.h
  /bin/sh: ldconfig: command not found
  WARNING: Could not find library file 'libsqlite3.so' in standard library directories.
   Defaulting to: '/Users/saladi/anaconda3/lib/libsqlite3.so'
     LIB: libsqlite3.so -> /Users/saladi/anaconda3/lib/libsqlite3.so

  WARNING: Could not find include file 'sqlite3.h' in standard include directories.
   Defaulting to: '/Users/saladi/anaconda3/include/sqlite3.h'
     INC: sqlite3.h -> /Users/saladi/anaconda3/include/sqlite3.h
  /bin/sh: ldconfig: command not found
  WARNING: Could not find library file 'libexpat.so' in standard library directories.
   Defaulting to: '/Users/saladi/anaconda3/lib/libexpat.so'
     LIB: libexpat.so -> /Users/saladi/anaconda3/lib/libexpat.so

  WARNING: Could not find include file 'expat.h' in standard include directories.
   Defaulting to: '/Users/saladi/anaconda3/include/expat.h'
     INC: expat.h -> /Users/saladi/anaconda3/include/expat.h
  /bin/sh: ldconfig: command not found
  WARNING: Could not find library file 'libnetcdf.settings' in standard library directories.
   Defaulting to: '/Users/saladi/anaconda3/lib/libnetcdf.settings'
     LIB: libnetcdf.settings -> /Users/saladi/anaconda3/lib/libnetcdf.settings

  WARNING: Could not find include file 'netcdf.h' in standard include directories.
   Defaulting to: '/Users/saladi/anaconda3/include/netcdf.h'
     INC: netcdf.h -> /Users/saladi/anaconda3/include/netcdf.h
  error: [Errno 20] Not a directory: '/Users/saladi/anaconda3/lib/libnetcdf.settings/libnetcdf.settings'

  ----------------------------------------
  Failed building wheel for vmd-python
  Running setup.py clean for vmd-python
Failed to build vmd-python
Installing collected packages: vmd-python
  Running setup.py install for vmd-python ... error
    Complete output from command /Users/saladi/anaconda3/bin/python -u -c "import setuptools, tokenize;__file__='/private/var/folders/ds/85_stvb54l77t3ddk3vtb2d40000gn/T/pip-build-2liosvpe/vmd-python/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /var/folders/ds/85_stvb54l77t3ddk3vtb2d40000gn/T/pip-0mi4mtxa-record/install-record.txt --single-version-externally-managed --compile:
    running install
    running build
    Compiling VMD
    Finding libraries...
    /bin/sh: ldconfig: command not found
    WARNING: Could not find library file 'libtcl8.5.so' in standard library directories.
     Defaulting to: '/Users/saladi/anaconda3/lib/libtcl8.5.so'
       LIB: libtcl8.5.so -> /Users/saladi/anaconda3/lib/libtcl8.5.so

    WARNING: Could not find include file 'tcl.h' in standard include directories.
     Defaulting to: '/Users/saladi/anaconda3/include/tcl.h'
       INC: tcl.h -> /Users/saladi/anaconda3/include/tcl.h
    /bin/sh: ldconfig: command not found
    WARNING: Could not find library file 'libsqlite3.so' in standard library directories.
     Defaulting to: '/Users/saladi/anaconda3/lib/libsqlite3.so'
       LIB: libsqlite3.so -> /Users/saladi/anaconda3/lib/libsqlite3.so

    WARNING: Could not find include file 'sqlite3.h' in standard include directories.
     Defaulting to: '/Users/saladi/anaconda3/include/sqlite3.h'
       INC: sqlite3.h -> /Users/saladi/anaconda3/include/sqlite3.h
    /bin/sh: ldconfig: command not found
    WARNING: Could not find library file 'libexpat.so' in standard library directories.
     Defaulting to: '/Users/saladi/anaconda3/lib/libexpat.so'
       LIB: libexpat.so -> /Users/saladi/anaconda3/lib/libexpat.so

    WARNING: Could not find include file 'expat.h' in standard include directories.
     Defaulting to: '/Users/saladi/anaconda3/include/expat.h'
       INC: expat.h -> /Users/saladi/anaconda3/include/expat.h
    /bin/sh: ldconfig: command not found
    WARNING: Could not find library file 'libnetcdf.settings' in standard library directories.
     Defaulting to: '/Users/saladi/anaconda3/lib/libnetcdf.settings'
       LIB: libnetcdf.settings -> /Users/saladi/anaconda3/lib/libnetcdf.settings

    WARNING: Could not find include file 'netcdf.h' in standard include directories.
     Defaulting to: '/Users/saladi/anaconda3/include/netcdf.h'
       INC: netcdf.h -> /Users/saladi/anaconda3/include/netcdf.h
    error: [Errno 20] Not a directory: '/Users/saladi/anaconda3/lib/libnetcdf.settings/libnetcdf.settings'

    ----------------------------------------
Command "/Users/saladi/anaconda3/bin/python -u -c "import setuptools, tokenize;__file__='/private/var/folders/ds/85_stvb54l77t3ddk3vtb2d40000gn/T/pip-build-2liosvpe/vmd-python/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /var/folders/ds/85_stvb54l77t3ddk3vtb2d40000gn/T/pip-0mi4mtxa-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /private/var/folders/ds/85_stvb54l77t3ddk3vtb2d40000gn/T/pip-build-2liosvpe/vmd-python/
Eigenstate commented 6 years ago

Oh man whoops I tried to do all this smart stuff with ldconfig to find the libraries, but it turns out this breaks the build on non-Linux systems. I will try to track down a Mac this week and fix it. I know older releases build on Macs, try: https://anaconda.org/rbetz/vmd-python/1.9.3/download/vmd-python-1.9.3.tar.gz

smsaladi commented 6 years ago

Sweet, thank you! That archive seemed to install fine (with python setup.py install, but it doesn't want to work, say when I just test importing at the command line. Feels like something weird is going on...

In [1]: import vmd
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-1-1ec58bc80a6c> in <module>()
----> 1 import vmd

~/anaconda3/lib/python3.5/site-packages/vmd_python-1.9.3-py3.5.egg/vmd/__init__.py in <module>()
     32
     33 # Load the library
---> 34 vmd = imp.load_dynamic(__name__, resource_filename(__name__, "libvmd.so"))
     35
     36 # These modules define classes for convenient manipulation of VMD state.

~/anaconda3/lib/python3.5/imp.py in load_dynamic(name, path, file)
    340         spec = importlib.machinery.ModuleSpec(
    341             name=name, loader=loader, origin=path)
--> 342         return _load(spec)
    343
    344 else:

ImportError: dlopen(/Users/saladi/anaconda3/lib/python3.5/site-packages/vmd_python-1.9.3-py3.5.egg/vmd/libvmd.so, 2): image not found
Eigenstate commented 6 years ago

Try python setup.py build then python setup.py install. Also, if you're in the directory of the archive it can complain about various things not being found. LMK if this works!

jjgoings commented 6 years ago

I had the same issue as OP, and tried using version 1.9.3, but running python setup.py build throws the error

user:~/vmd-python-1.9.3 $ python setup.py build
running build
Compiling VMD
Traceback (most recent call last):
  File "setup.py", line 180, in <module>
    'test': VMDTest,
  File "/anaconda/lib/python3.6/distutils/core.py", line 148, in setup
    dist.run_commands()
  File "/anaconda/lib/python3.6/distutils/dist.py", line 955, in run_commands
    self.run_command(cmd)
  File "/anaconda/lib/python3.6/distutils/dist.py", line 974, in run_command
    cmd_obj.run()
  File "setup.py", line 34, in run
    self.execute(self.compile, [], msg="Compiling VMD")
  File "/anaconda/lib/python3.6/distutils/cmd.py", line 335, in execute
    util.execute(func, args, msg, dry_run=self.dry_run)
  File "/anaconda/lib/python3.6/distutils/util.py", line 301, in execute
    func(*args)
  File "setup.py", line 49, in compile
    self.set_environment_variables(pydir)
  File "setup.py", line 96, in set_environment_variables
    pythonldflag = libs[-1].split('/')[-1].replace("lib","-l").replace(".so","")
IndexError: list index out of range

It appears pythonldflag is empty, so somehow the libraries aren't being found. I'm using MacOS 10.12.6. This was with python3.6, but the same error shows up with python2.7, if that matters.

Eigenstate commented 6 years ago

I've fixed these problems, and it should build on OSX now. I've updated the pip build as well as adding a binary for 64 bit OSX + Python 3.6

jjgoings commented 6 years ago

Was able to build from source on macOS Sierra 10.12.6, after resolving dependencies (needed libnetcdf and libexpat, but that's what I get for not reading the README). I wasn't able to get pip build to work; still had issues finding the correct libraries.

Running pip install -i https://pypi.anaconda.org/rbetz/simple vmd-python gives

Collecting vmd-python
  Downloading https://pypi.anaconda.org/rbetz/simple/vmd-python/2.0.1/vmd-python-2.0.1.tar.gz (28.4MB)
    100% |████████████████████████████████| 28.4MB 30kB/s
Building wheels for collected packages: vmd-python
  Running setup.py bdist_wheel for vmd-python ... error
  Complete output from command /anaconda/bin/python -u -c "import setuptools, tokenize;__file__='/private/var/folders/31/5s9bl7y14ybcqqhrrpd_tfd00000gn/T/pip-build-wo4o4ktg/vmd-python/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d /var/folders/31/5s9bl7y14ybcqqhrrpd_tfd00000gn/T/tmpwedk1zw7pip-wheel- --python-tag cp36:
  running bdist_wheel
  running build
  Compiling VMD
  Finding libraries...
  /bin/sh: ldconfig: command not found
  WARNING: Could not find library file 'libtcl8.5.so' in standard library directories.
   Defaulting to: '/anaconda/lib/libtcl8.5.so'
     LIB: libtcl8.5.so -> /anaconda/lib/libtcl8.5.so

  WARNING: Could not find include file 'tcl.h' in standard include directories.
   Defaulting to: '/anaconda/include/tcl.h'
     INC: tcl.h -> /anaconda/include/tcl.h
  /bin/sh: ldconfig: command not found
  WARNING: Could not find library file 'libsqlite3.so' in standard library directories.
   Defaulting to: '/anaconda/lib/libsqlite3.so'
     LIB: libsqlite3.so -> /anaconda/lib/libsqlite3.so

  WARNING: Could not find include file 'sqlite3.h' in standard include directories.
   Defaulting to: '/anaconda/include/sqlite3.h'
     INC: sqlite3.h -> /anaconda/include/sqlite3.h
  /bin/sh: ldconfig: command not found
  WARNING: Could not find library file 'libexpat.so' in standard library directories.
   Defaulting to: '/anaconda/lib/libexpat.so'
     LIB: libexpat.so -> /anaconda/lib/libexpat.so

  WARNING: Could not find include file 'expat.h' in standard include directories.
   Defaulting to: '/anaconda/include/expat.h'
     INC: expat.h -> /anaconda/include/expat.h
  /bin/sh: ldconfig: command not found
  WARNING: Could not find library file 'libnetcdf.settings' in standard library directories.
   Defaulting to: '/anaconda/lib/libnetcdf.settings'
     LIB: libnetcdf.settings -> /anaconda/lib/libnetcdf.settings

  WARNING: Could not find include file 'netcdf.h' in standard include directories.
   Defaulting to: '/anaconda/include/netcdf.h'
     INC: netcdf.h -> /anaconda/include/netcdf.h
  error: [Errno 20] Not a directory: '/anaconda/lib/libnetcdf.settings/libnetcdf.settings'

It's still invoking ldconfig, which I don't think is the desired behavior in macOS for finding libraries.