Main Application Platform:
Application Version: SeaDAS 8.3.0
SNAP Engine Version: 9.0.3* (SeaDAS Platform modified)
SNAP Desktop Version: 9.0.3* (SeaDAS Platform modified)
SNAP Engine Build Date: 202212081832
SNAP Desktop Build Date: 202212081837
Python3 Directory: /usr/local/bin/python3
I need to SeaDAS to use a different Python3 Directory. I have an existing Python virtual environment that has the requests package needed by SeaDAS, but I can't find documentation on how to point SeaDAS to a different Python3 Directory.
- Subject Matter Expert
- Posts: 632
- Joined: Tue Feb 09, 2021 5:42 pm America/New_York
- Been thanked: 1 time
Code: Select all
/usr/local/bin/pip3 install requests
Code: Select all
You didn't mention which of the many virtual environments you use, but just run SeaDAS from the shell prompt in a terminal with the Python environment that provides the requests package, see: https://realpython.com/python-virtual-environments-a-primer/#activate-it.
(venv-py3.10) $ which python
(venv-py3.10) $ which python3
(venv-py3.10) $ ~/Applications/SeaDAS/bin/seadas
The answers indicate there is not a way to configure SeaDAS. I'll keep trying ways to make it recognize the PATH variable set by the virtual environment.
@gnwii I use Python's own venv, not conda, in case that's what you were wondering.
@OB SeaDAS - xuanyang02 I do not mess with /usr/local/bin. I only let Homebrew do that. As a fallback though, I will `/usr/local/bin/python3 -m pip install --user requests`.
See: https://whiteboxml.com/blog/the-definitive-guide-to-python-virtual-environments-with-conda. I'm currently using Fedora Linux, which provides an immutable conda base environment, no connection to Anaconda Python.@gnwii I use Python's own venv, not conda, in case that's what you were wondering.
Starting SeaDAS 8 from the command line in a terminal with a conda env active "works for me", but macOS has been messing with the way the PATH is set for Finder Applications:
https://apple.stackexchange.com/questions/51677/how-to-set-path-for-finder-launched-applications has examples for many macOS versions. It seems the easy solution is to have a python in the default path with requests, so the suggestion to install requests for your /usr/local/bin/python3 should work.
Locate the seadas_setup.sh script. This script is typically located in the SeaDAS installation directory, under the ocssw subdirectory.
Open the seadas_setup.sh script in a text editor.
Locate the line that sets the OCSSW_PYTHON environment variable. By default, this line will look like this:
This line sets the OCSSW_PYTHON environment variable to use the system Python interpreter.
Modify the OCSSW_PYTHON environment variable to point to the Python interpreter that you want to use. For example, if you want to use a Python virtual environment located at /path/to/venv, you can set the OCSSW_PYTHON environment variable like this:
This will make SeaDAS use the Python interpreter located in the virtual environment.
Save the seadas_setup.sh script.
Restart any open SeaDAS terminals or shells to ensure that the new environment variables take effect.
After following these steps, SeaDAS should be configured to use the Python interpreter that you specified. You can confirm that SeaDAS is using the correct Python interpreter by running the python command within the SeaDAS environment and verifying that it is using the expected Python version and packages.
To know more about this kind of setup with find visit: https://www.enablegeek.com/tutorial_series/python/