Check out this tutorial demonstrating Python interoperability in Swift.
This function is intended to set the Python version before any references to the global PythonInterface
called Python
-
it cannot be used to switch Python versions dynamically.
This could be better designed/documented so that people don't get the impression that switching Python versions is possible.
Special environment variables (defined here)
-
PYTHON_LIBRARY
(sets the Python library path, useful for setting a specific Python version)Examples:
export PYTHON_LIBRARY="~/anaconda2/lib/libpython2.7.so" export PYTHON_LIBRARY="~/anaconda3/lib/libpython3.7m.so" # Then, rerun Swift.
-
PYTHON_VERSION
(forces a specific Python version) -
PYTHON_LOADER_LOGGING
(enables library loading debug log)
problem with gist is - can't do PR. I solved my setup on osx with miniconda3
export PYTHON_LIBRARY="~/miniconda3/lib/libpython3.7m.dylib"
https://gist.github.com/johndpope/0933050234e5d5b7a17a4e6a6ab6c3d4