pysat / pysatCDF

Python reader for NASA CDF file format
BSD 3-Clause "New" or "Revised" License
10 stars 7 forks source link

Installing with pip #15

Closed asher-pembroke closed 4 years ago

asher-pembroke commented 4 years ago

I ran into problems installing with pip involving the notorious libgfortran rpath bug on mac.

To reproduce,

  1. pip pysatCDF on a mac anaconda/miniconda environment (python 2.7)
  2. import pysatCDF
  3. raises something like this
ImportError: dlopen(/Users/apembrok/Library/Caches/Python-Eggs/pysatCDF-0.3.0-py2.7-macosx-10.6-x86_64.egg-tmp/pysatCDF/fortran_cdf.so, 2): Library not loaded: @rpath/./libgfortran.3.dylib
  Referenced from: /Users/apembrok/Library/Caches/Python-Eggs/pysatCDF-0.3.0-py2.7-macosx-10.6-x86_64.egg-tmp/pysatCDF/fortran_cdf.so
  Reason: image not found

To resolve:

  1. verify the existing library names assigned to fortran_cdf.so: otool -L ${CONDA_PREFIX}/lib/python2.7/site-packages/pysatCDF/fortran_cdf.so
  2. modify the library names with install_name_tool:
    install_name_tool -change @rpath/./libgfortran.3.dylib ${CONDA_PREFIX}/lib/libgfortran.dylib -change @rpath/./libquadmath.0.dylib ${CONDA_PREFIX}/lib/libquadmath.0.dylib fortran_cdf.so ${CONDA_PREFIX}/lib/python2.7/site-packages/pysatCDF/fortran_cdf.so

Conda package installers usually fix the rpath issue automagically. Not sure how to do this with setuptools...

rstoneback commented 4 years ago

Thanks Asher.

Since you have the terminal command can’t you invoke that from setup.py?

I believe there is a post-install trigger in setuptools and the package has the paths and such the final code is, or will be, when installed.

On Oct 9, 2019, at 5:25 PM, Asher Pembroke notifications@github.com<mailto:notifications@github.com> wrote:

I ran into problems installing with pip involving the notorious libgfortran rpath bughttps://nam02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FContinuumIO%2Fanaconda-issues%2Fissues%2F739&data=02%7C01%7Crstoneba%40utdallas.edu%7Ca340e93046f74b7db90808d74d07840f%7C8d281d1d9c4d4bf7b16e032d15de9f6c%7C0%7C0%7C637062566996679415&sdata=rc%2FB%2FjvgNM5g9Bqqg18SM35sz%2FwZAT9A0%2BnIgCHgO%2B8%3D&reserved=0 on mac.

To reproduce,

  1. pip pysatCDF on a mac anaconda/miniconda environment (python 2.7)
  2. import pysatCDF
  3. raises something like this

ImportError: dlopen(/Users/apembrok/Library/Caches/Python-Eggs/pysatCDF-0.3.0-py2.7-macosx-10.6-x86_64.egg-tmp/pysatCDF/fortran_cdf.so, 2): Library not loaded: @rpath/./libgfortran.3.dylib Referenced from: /Users/apembrok/Library/Caches/Python-Eggs/pysatCDF-0.3.0-py2.7-macosx-10.6-x86_64.egg-tmp/pysatCDF/fortran_cdf.so Reason: image not found

To resolve:

  1. verify the existing library names assigned to fortran_cdf.so: otool -L ${CONDA_PREFIX}/lib/python2.7/site-packages/pysatCDF/fortran_cdf.so
  2. modify the library names with install_name_tool:

install_name_tool -change @rpath/./libgfortran.3.dylib ${CONDA_PREFIX}/lib/libgfortran.dylib -change @rpath/./libquadmath.0.dylib ${CONDA_PREFIX}/lib/libquadmath.0.dylib fortran_cdf.so ${CONDA_PREFIX}/lib/python2.7/site-packages/pysatCDF/fortran_cdf.so

Conda package installers usually fix the rpath issue automagically. Not sure how to do this with setuptools...

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHubhttps://nam02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fpysat%2FpysatCDF%2Fissues%2F15%3Femail_source%3Dnotifications%26email_token%3DAA3N26OTHLX7XF5ZZFUKPXDQNZK3RA5CNFSM4I7FQAO2YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4HQYS4PA&data=02%7C01%7Crstoneba%40utdallas.edu%7Ca340e93046f74b7db90808d74d07840f%7C8d281d1d9c4d4bf7b16e032d15de9f6c%7C0%7C0%7C637062566996684412&sdata=85mQh0BoPZFRR%2BFUtkuf1TMh8XeaXzQtrV2ekb5BycM%3D&reserved=0, or unsubscribehttps://nam02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAA3N26OAJ4EKFGRJ4F7WEHDQNZK3RANCNFSM4I7FQAOQ&data=02%7C01%7Crstoneba%40utdallas.edu%7Ca340e93046f74b7db90808d74d07840f%7C8d281d1d9c4d4bf7b16e032d15de9f6c%7C0%7C0%7C637062566996694418&sdata=JNtDUr8Lm58LInjLr%2FOkd2CeEStEJMRn%2BGTjlDqpwzo%3D&reserved=0.

dcsozturk commented 4 years ago

Hi, I also run into a problem trying to install pysat, pysatCDF, and pysatMagVect with pip. It is not directly relevant but I was hesitant to start a new issue, since it is technically an "installation with pip issue". Please feel free to move/edit as you see fit.

I have the following:

I get a bunch of warnings during installation, all seem to be related with the incompatibility between Apple clang and gfortran versions I installed with Homebrew. To fix I had to define new aliases in my bashrc file to point the gcc and gfortran installed by brew in my /usr/local/bin/.

The problem is similar to https://github.com/pymc-devs/pymc/issues/119

rstoneback commented 4 years ago

Thanks for the report.

Cheers

asher-pembroke commented 4 years ago

A lot of places suggest the delocate tool which makes pip wheels portable. That would at least solve the issue where users aren't able to install with pip.

asher-pembroke commented 4 years ago

Also, note that install_name_tool requires users to have the xcode developer tools installed so putting the command in setup.py may not help: https://stackoverflow.com/a/11598098

rstoneback commented 4 years ago

The delocate looks like it would be helpful for pip.

asher-pembroke commented 4 years ago

I found a lot of issues with clang as well, but gcc seems to work better.

I'm able to install from setup.py using the following environment setup

conda create -n pysatCDF python=2.7
conda install -c anaconda gcc
conda install -c anaconda numpy
pip install pysat (or setup.py after cloning pysat)

Then, from pysatCDF directory:

python setup.py install (or pip install .)

@rstoneback Anything left to do here?

rstoneback commented 4 years ago

Does it work in python 3? If it’s good then I think we are good.

Cheers, Russell

On Nov 4, 2019, at 11:41 AM, Asher Pembroke notifications@github.com wrote:



I found a lot of issues with clang as well, but gcc seems to work better.

I'm able to install from setup.py using the following environment setup

conda create -n pysatCDF python=2.7 conda install -c anaconda gcc conda install -c anaconda numpy pip install pysat (or setup.py after cloning pysat)

Then, from pysatCDF directory:

python setup.py install (or pip install .)

@rstonebackhttps://nam02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Frstoneback&data=02%7C01%7Crstoneba%40utdallas.edu%7Cb069f242f989454df8a508d7615696cb%7C8d281d1d9c4d4bf7b16e032d15de9f6c%7C0%7C0%7C637084896840415726&sdata=Bl8QmPA%2Fl4M4J42nXjrokOeJegJzySj2Via2ZNGLtug%3D&reserved=0 Anything left to do here?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://nam02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fpysat%2FpysatCDF%2Fissues%2F15%3Femail_source%3Dnotifications%26email_token%3DAA3N26IKPUCQAZTGBTKYGWLQSBUFDA5CNFSM4I7FQAO2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEDAJBOI%23issuecomment-549490873&data=02%7C01%7Crstoneba%40utdallas.edu%7Cb069f242f989454df8a508d7615696cb%7C8d281d1d9c4d4bf7b16e032d15de9f6c%7C0%7C0%7C637084896840415726&sdata=10Z8DrzWjEj4o4IiA2M3VMXfAmTxP12kx0MUWofVTdc%3D&reserved=0, or unsubscribehttps://nam02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAA3N26IDQSLKCG7X5M2ZRPTQSBUFDANCNFSM4I7FQAOQ&data=02%7C01%7Crstoneba%40utdallas.edu%7Cb069f242f989454df8a508d7615696cb%7C8d281d1d9c4d4bf7b16e032d15de9f6c%7C0%7C0%7C637084896840425720&sdata=uaYV7TXuaLXfMDOpc%2BsIz%2BJSdOLaYBz%2FhF0OmnMKa5w%3D&reserved=0.

asher-pembroke commented 4 years ago

Yep, it works with python3 as well.

rstoneback commented 4 years ago

I've uploaded delocated versions of pysatCDF to pypi for macosx. python 2 and 3.8 are currently supported.

aburrell commented 4 years ago

I was finally able to fix various issues and got pysatCDF to install on my laptop (OSX Mojave) with python 2.7, 3.7, and 3.8.

rstoneback commented 4 years ago

Great!