rca / PySPICE

Python wrapper around the NAIF CSPICE library
http://naif.jpl.nasa.gov/naif/
BSD 3-Clause "New" or "Revised" License
38 stars 15 forks source link

install in anaconda + brew environment? #16

Closed ifmihai closed 10 years ago

ifmihai commented 10 years ago

Im on a mac, mavericks 10.9.4, anaconda latest version, brew latest version

For now, I've installed cspice with brew

but now I'm not sure what to do, as I'm by no means a python or linux expert

Can someone point me in the right direction?

michaelaye commented 10 years ago

wow, thanks for letting me know that brew offers cspice, who knew? You have to find out in what folder cspice is installed, and create a symlink to the PySPICE folder:

cd to_pyspice
ln -s path/to/cspice cspice

then follow the readme.

ifmihai commented 10 years ago

I'm glad brew offers cspice also of course :)

But then, pySPICE will be installed in where exactly? in anaconda distribution?

michaelaye commented 10 years ago

oh, yes. but only if the python compiler that is used in the moment for the setup.py install command is the one from anaconda. So you have to adapt the paths correctly before you do the install. Check with

which python

If the path does not mention anaconda, then u r not done yet. After the install is done, you will be able to do:

import spice

and find the usual spice functions (not all, alas) under the spice module namespace. If half of what I say sounds strange to you, I urge you to at least go through the Python tutorial on python.org and for the calculations, go through a numpy tutorial. Don't waste time for understanding the depths of Python installs yet, I only learned that after using Python for years, and it can be frustrating.

ifmihai commented 10 years ago

Some quirks:

  1. brew installs into /usr/loca/Cellar/cspice/64 I checked ln command so the ln command had to be: ln -s /usr/local/Cellar/cspice/64 cspice
  2. python setup.py build_ext worked
  3. python setup.py install worked also. (although, i see mentions of macosx-10.5 in there)
  4. i tried python import spice but it throws exception:
1 In : import spice
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-1-895c03879cbe> in <module>()
----> 1 import spice

/Users/ifmichael/github/PySPICE/spice/__init__.py in <module>()
      1 # Released under the BSD license, see LICENSE for details
      2
----> 3 from misc import *
      4 from objects import *

/Users/ifmichael/github/PySPICE/spice/misc.py in <module>()
      1 # Released under the BSD license, see LICENSE for details
      2
----> 3 from _spice import *

ImportError: dynamic module does not define init function (init_spice)
michaelaye commented 10 years ago
  1. is the 64 in above path a folder? It has to be for this to work.
  2. Did it produce the file spicemodule.c? If not, it did not work properly.
  3. I'm afraid that sounds like brew installs this as a dynamic module library, and I don't believe we support that.

/cc @rca ?

If my worry is true, you would have to remove brew's cspice (just to be clean) and install the 64-bit cspice folder that you can download from the NAIF SPICE website directly. I have exactly your setup, so I'm convinced that that way works, I am running it now like that.

ifmihai commented 10 years ago
  1. yes. 64 is a folder. otherwise it couldn't work, i guess
  2. yes. I see the spice module.c in root
  3. i don't know how dynamic module library is different than a "normal" library, but I will look into it.

well, if downloading from NAIF SPICE website works, then great! I try again.

  1. downloaded version 65. unzip. copy cspice to pyspice folder
  2. I wondered "wouldn't it be more convenient to have cspice already in pySPICE git repository? as spice version reached 65 from what I see"
  3. python setup.py build_ext it throws exception apparently
79-117-239-118:PySPICE ifmichael$ python setup.py build_ext
making wrapper
Traceback (most recent call last):
  File "setup.py", line 84, in <module>
    make_spice_module()
  File "setup.py", line 67, in make_spice_module
    f.write(mkwrapper.main(CSPICE_SRC))
  File "/Users/ifmichael/github/PySPICE/mkwrapper.py", line 1004, in main
    if gen_wrapper(curr_prototype, buffer):
  File "/Users/ifmichael/github/PySPICE/mkwrapper.py", line 259, in gen_wrapper
    param_info = parse_param(param)
  File "/Users/ifmichael/github/PySPICE/mkwrapper.py", line 837, in parse_param
    raise msg
ValueError: invalid literal for int() with base 10: ''

[EDIT] I started from scratch with PySPICE also. fresh everything.

michaelaye commented 10 years ago

Confirmed. That's a new problem with version 65, note that this version was released on July 23rd. Workaround: Use version 64 from here, I just reconfirmed that it works with this version: https://www.dropbox.com/s/z62rouwhbt9nc2o/cspice_64.tar.Z

ifmihai commented 10 years ago

I did fresh everything again.

but in ipython, when import spice it throws the same exception as in the beginning:

1 In : import spice
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-1-895c03879cbe> in <module>()
----> 1 import spice

/Users/ifmichael/.Trash/PySPICE/spice/__init__.py in <module>()
      1 # Released under the BSD license, see LICENSE for details
      2
----> 3 from misc import *
      4 from objects import *

/Users/ifmichael/.Trash/PySPICE/spice/misc.py in <module>()
      1 # Released under the BSD license, see LICENSE for details
      2
----> 3 from _spice import *

ImportError: dynamic module does not define init function (init_spice)

I suspect something must be wrong on my side, if you say it works in your case.

Actually, I see it's not the same exception Somehow it access the trashed PySPICE (!?!)

ifmihai commented 10 years ago

It was because github I presume, or unpacker or both I deleted trash completely cloned again copied spice 64 from your source and now it works!

tbroiles commented 10 years ago

I was also unable to properly install Pyspice with cspice 65, but was able to with the previous version that michaelaye provided. I'm running Python 2.7.8 on OSX 10.9.4. Additionally, it's worth noting that the problem seemed to be occurring with spicemodule.c that makewrapper.py was creating. In cspice 65, it would be generated, but would be blank.

michaelaye commented 10 years ago

I close this because it has lot's of other stuff in the issue that is unrelated. We have a duplicate report in #17 that I keep open.