[Solved] Python: Code with numpy+astropy works in cmd.exe, but produces error message in TD

Edit: I probably had the 32 bit versions of the libraries left from a previous Python installation.
Doing pip uninstall and then pip install worked.

System info

  • Python 3.7.2
  • Windows 10.0.18363
  • TouchDesigner 2019.37030

Explanation

The code below works in a .py file on my desktop.

If I run the same code from a text DAT, I get an error message. TouchDesigner does locate both libraries correctly though, as shown further down.

Code from https://docs.astropy.org/en/stable/coordinates/solarsystem.html

import numpy
from astropy.time import Time
from astropy.coordinates import solar_system_ephemeris, EarthLocation
from astropy.coordinates import get_body_barycentric, get_body, get_moon

t = Time("2014-09-22 23:22")
loc = EarthLocation.of_site('greenwich') 

with solar_system_ephemeris.set('builtin'):
    jup = get_body('jupiter', t, loc) 

print(jup)

Output from cmd.exe:

Output from TouchDesigner:

Here’s what I get with just the import statements:

import numpy
from astropy.time import Time
from astropy.coordinates import solar_system_ephemeris, EarthLocation
from astropy.coordinates import get_body_barycentric, get_body, get_moon

If I just do “print(numpy)” and “print(astropy)”, I get their locations. TouchDesigner is able to locate them, so I’m confused why the code works in cmd.exe, but not in TouchDesigner:

image

I might start debugging this by looking at the versions for numpy and astropy that touch is using, and compare that against what’s in your command line. Wrangling these things is always a headache, so hang in there.

1 Like

I got it working!

I had installed the correct 64 bit version of Python 3.7.2, but I must have had the 32 bit versions of the libraries installed. Doing pip uninstall and then pip install did the trick.