Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python SML client uses hard-coded Python library path #504

Open
analog-cbarber opened this issue Sep 23, 2024 · 1 comment
Open

Python SML client uses hard-coded Python library path #504

analog-cbarber opened this issue Sep 23, 2024 · 1 comment

Comments

@analog-cbarber
Copy link

I downloaded the 9.6.3 distribution and ran setup.sh on a Mac M1. When I tried to import the SML client package, I got this error:

(soar) SoarSuite/bin % python
Python 3.12.6 | packaged by conda-forge | (main, Sep 22 2024, 14:07:06) [Clang 17.0.6 ] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import Python_sml_ClientInterface
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/Christopher.Barber/SoarSuite_9.6.3-Multiplatform/bin/Python_sml_ClientInterface.py", line 12, in <module>
    import _Python_sml_ClientInterface
ImportError: dlopen(/Users/Christopher.Barber/SoarSuite_9.6.3-Multiplatform/bin/_Python_sml_ClientInterface.so, 0x0002): Library not loaded: /Library/Frameworks/Python.framework/Versions/3.12/Python
  Referenced from: <08B46C96-24A4-3078-88D3-8A62B481CFC4> /Users/Christopher.Barber/SoarSuite_9.6.3-Multiplatform/bin/_Python_sml_ClientInterface.so
  Reason: tried: '/Library/Frameworks/Python.framework/Versions/3.12/Python' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/Library/Frameworks/Python.framework/Versions/3.12/Python' (no such file), '/Library/Frameworks/Python.framework/Versions/3.12/Python' (no such file)

It looks like it is assuming that Python 3.12 has been installed using the public Python installer, but it is actually common for people to install python using other tools that put it in other places. In my case, it is installed in a specific conda environment.

Not sure if there is an environment variable I can set to fix this or if I have to just build it myself.

Ideally, the code should not use any hard coded paths and instead should get the location of the Python library from the python process doing the import.

It would also be useful if the download explicitly specified which version of python it was compiled for.

@analog-cbarber
Copy link
Author

One workaround is to use the install_name_tool to rewrite the location of the python executable to the one you are using, e.g.:

$ install_name_tool -change /Library/Frameworks/Python.framework/Versions/3.12/Python /Users/jdoe/miniforge3/bin/python _Python_sml_ClientInterface.so

Perhaps this could be done in the setup.sh script using which python to find the executable?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant