Can't get Snappy to interpret my code? [gpt <operator> -h]

I’m not sure why I keep getting this error? I just want the list of operators and their required parameters. “bin” is exactly where gpt is located. What’s up?

You have GParted installed. this is also abbreviated by gpt.
Use the full path to SNAP gpt instead and it should work.

Sorry, I’m really new to this. Could you elaborate? Full as in " cd bin/gpt"?

From you command i think you need to use:
/Applications/snap/bin/gpt

Nope. Not working.

But this is the folder where you find a gpt, pconvert and snap executable, right?

I’m not very familiar with Mac.
Maybe someone can jump in here, and tell jsmith2 how to call gpt with the full path?

Yes - seems to be all there.

I’m having trouble calling any function from Snappy in general too. I always get an error.
For example:

It has been several years since I had access to macOS, so between my unreliable memory and changes such as using zsh in place of bash in a terminal, the following may need updating:

There are multiple 3rd party libraries called snappy (try a Goggle search for “Python snappy library”). This isn’t a problem if you use a minimal Python distribution from Python.org, but if you use Python with apps other than SNAP they may pull in a different snappy library. Python has a mechanism to provide better control over the choice of a snappy library. This is mentioned in Configure Python to use the SNAP-Python (snappy) interface. Search in this page of USERPROFILE and you will see the example for a Windows system. You should have a $HOME\.snap (hidden) directory. On linux or macOS, ls ~/.snap/snap-python/snappy in a bash or zsh terminal should display the contents of the ESA SNAP library, including examples and testdata directories. If so, you can replace USERPROFILE with HOME in the line that defines snappy_envar:

snappy_envar = 'HOME'

Thanks so much for your help - I feel I am getting somewhere now. However, I ran into this error while trying to manually configure. I had to do this once I realized it wasn’t working when I checked “configure Python with SNAP” during the initial installation. Any tips what’s up?

I was able to access the error, but I’m not sure what it means? I installed jpy several days ago.:

INFO: Installing from Java module ‘/Applications/snap/snap/modules/org-esa-snap-snap-python.jar’
INFO: Installing jpy…
ERROR: The module ‘jpy’ is required to run snappy, but no binary ‘jpy’ wheel matching the pattern
‘jpy-{version}-cp38-{abi_tag}-macosx_10_14_6_x86_64.whl’ could be found.
You can try to build a ‘jpy’ wheel yourself, then copy it into
“/Users/jsmith/.snap/snap-python/snappy”, and then run the configuration again.
Unzip the jpy sources in /Users/jsmith/.snap/snap-python/snappy/jpy-.zip, then
cd jpy-<version> python setup.py bdist_wheel
cp dist/*.whl "/Users/jsmith/.snap/snap-python/snappy" Or get the source code from https://github.com/bcdev/jpy and follow the build instructions: git clone https://github.com/bcdev/jpy.git
$ cd jpy
ERROR: Configuration failed with exit code 10

It looks like your /usr/bin/python3 is Python 3.8. You can check by running /usr/bin/python3 --version in a terminal. You can either install Python 3.6 (which will allow you to use a well-tested jpy version), find a jpy that was built for Python 3.8 on
macOS, or build jpy yourself (not a suitable project for someone with little software development exerience). In general, it is best to avoid using Apple’s Python as it is intended for support of system maintenance scripts and could be changed at any
macOS update. Many people use Anaconda Python (which will install a current Python3 version, but also supports older Python versions using “environments”,
so you can have a SNAP Python3 environment). This is well-documented on the Anaconda site.

So what do you recommend best here? Reverting to 3.6? I’m downloading Anaconda now.

So now I’m at this stage of problems. Also not sure how to diagnose:

If you have python 3.6 you don’t need to build jpy. In Configure Python to use the SNAP-Python (snappy) interface there are instructions to manually install SNAP snappy using the command line. You need to use a terminal with your Anaconda py36 environment. In the ternminal, navigate to the <snap-install-dir>/bin folder containing snappy-conf (as shown in a previous post). You can determine the path of your python 3.6 program (<python-exe>) by running which python. Then run the “Unix” form (.\snappy-conf <python-exe>) and if that succeeds you can continue to the test. Note that <snappy-dir> should be ~/.snap/snap-python.

I get the exact same error:

??

Previoiusly, you had:

The installed tries to use an existing jpy module from org-esa-snap-snap-python.jar by OS version, Python version, and architecture.

In this error, the -cp38- means the installation was run using “C” Python 3.8. Can you show us the log file (~/.snap/snap-python/snappy/snappyutil.log)?

Sure thing. Using a 3.6 environment, here it is:

Other question: what is a wheel?

A wheel is a binary package. SNAP provides a bunch of wheels in org-esa-snap-snap-python.jar. You can only use a wheel that matches the python program version and runtime libraries. It looks like your Anaconda environment provides python 3.6 built for a macOS 10.9 (Mavericks, ca 2013) runtime. Java .jar files are archives, and you can list the contents:

% jar tf org-esa-snap-snap-python.jar |grep macos
lib/jpy-0.9.0-cp27-cp27m-macosx_10_12_x86_64.whl
lib/jpy-0.9.0-cp34-cp34m-macosx_10_12_x86_64.whl
lib/jpy-0.9.0-cp35-cp35m-macosx_10_12_x86_64.whl
lib/jpy-0.9.0-cp36-cp36m-macosx_10_12_x86_64.whl

So jpy was built for macOS 10.12 (Sierra). The last Python 3.6 binary for macOS from python.org was also for 10.9. If you can’t find a more recent Python-3.6 you are stuck with building jpy yourself. Maybe the developers can suggest a way to install a suitable python-3.6 (there are several system that package open-source softoware).

Your attempt to build a jpy wheel failed because you didn’t provide the required Java Development environment. To go this route you need to install a full openJDK 1.8 Java Development package and set an environment variable (JAVA_HOME) to the location of the package. Conda-forge provides a wide variety of open-source packages that are available from the Anaconda servers, including openJDK.

You may want to look for a forum devoted to macOS Big Sur for help getting a suitable python 3.6 or openJDK.

Thanks for your response.

I find a lot of this difficult to understand. So I need to try and install the newest version of Python 3.6 (3.6.11?) for this to work?

I keep seeing threads about how to set this java_home variable but I can’t understand what I’m reading. Is there any very clear, explicit documentation?

I’m on Catalina 10.15.7 BTW.

There is a good chance that a newer Python 3.6 version will have been built on a more recent macOS version that can use the existing jpy binary wheel.

Conda packages contain metadata that provides the build configuration, so might tell you the target macOS versions, but it doesn’t appear to be searchable on the Anaconda site.

The minor updates to Python 3.6 aren’t critical to SNAP – what matters is that the Python 3.6 runtime library used to run jpy is compatible with the libraries used to build the binary wheel (e.g. 10.12). There are many other sources of Python 3.6 for macOS, but even the experts get into difficulties, see The best way to install Python on a Mac (and avoid having your Mac declared a superfund site). This assumes basic command-line expertise (and even the authors had some problems with macOS).

If you can’t find a working python 3.6 then you will need to build your own binary wheel. Before attempting that you should step back and bone up on command-line basics. Scripting OSX is a good place to start, and Linux Command written for bash and linux is 95% relevant to macOS and zsh may be helpful.