HiGHS: ImportError for `highspy`

Hello, I’m on an M1 Mac (MacOS Ventura, Python 3.10.9) and downloaded HiGHS via PyPI (highspy) and am getting this import error.

I didn’t seen any similar issues asked previously, so I figured I’d ask here. Appreciate any help!

Python 3.10.9 (main, Jan 11 2023, 09:18:20) [Clang 14.0.6 ] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import highspy
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/e3-work/opt/anaconda3/envs/nmt-pins/lib/python3.10/site-packages/highspy/__init__.py", line 1, in <module>
    from .highs import (
  File "/Users/e3-work/opt/anaconda3/envs/nmt-pins/lib/python3.10/site-packages/highspy/highs.py", line 1, in <module>
    from .highs_bindings import (
ImportError: dlopen(/Users/e3-work/opt/anaconda3/envs/nmt-pins/lib/python3.10/site-packages/highspy/highs_bindings.cpython-310-darwin.so, 0x0002): symbol not found in flat namespace '__ZN5Highs10clearModelEv'

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Reactions: 2
  • Comments: 30 (17 by maintainers)

Most upvoted comments

Hi @alspadoni, this actually is with high priority. I can not give you an exact time, but we expect to have it resolved sooner rather than later.

@goroderickgo You will need to compile and install manually

git clone https://github.com/ERGO-Code/HiGHS.git
cd HiGHS
git checkout latest
mkdir build 
cd build 
cmake .. 
make
make install 
pip install ../src/interfaces/highspy/

I installed via pip and obtained the same error:

macbook: ~  % pip install highspy
Collecting highspy
  Using cached highspy-1.5.0.dev0-cp310-cp310-macosx_10_9_x86_64.whl (236 kB)
Collecting pybind11
  Using cached pybind11-2.10.3-py3-none-any.whl (222 kB)
Collecting pyomo
  Using cached Pyomo-6.4.4-cp310-cp310-macosx_10_15_x86_64.whl (4.8 MB)
Collecting numpy
  Using cached numpy-1.24.2-cp310-cp310-macosx_10_9_x86_64.whl (19.8 MB)
Collecting ply
  Using cached ply-3.11-py2.py3-none-any.whl (49 kB)
Installing collected packages: ply, pyomo, pybind11, numpy, highspy
Successfully installed highspy-1.5.0.dev0 numpy-1.24.2 ply-3.11 pybind11-2.10.3 pyomo-6.4.4
macbook: ~  % python3
Python 3.10.9 (main, Dec 15 2022, 18:25:35) [Clang 14.0.0 (clang-1400.0.29.202)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import highspy
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.10/site-packages/highspy/__init__.py", line 1, in <module>
    from .highs import (
  File "/usr/local/lib/python3.10/site-packages/highspy/highs.py", line 1, in <module>
    from .highs_bindings import (
ImportError: dlopen(/usr/local/lib/python3.10/site-packages/highspy/highs_bindings.cpython-310-darwin.so, 0x0002): symbol not found in flat namespace '__ZN5Highs10clearModelEv'
>>>

I am on Intel macOS 13.

Hi,

I have the same error:

ImportError: dlopen(…opt/anaconda3/envs/test/lib/python3.9/site-packages/highspy/highs_bindings.cpython-39-darwin.so, 0x0002): symbol not found in flat namespace ‘__ZN5Highs10clearModelEv’

I’m using Apple M2 chip and installed highspy using pip.

For me the following did the trick:

git clone https://github.com/ERGO-Code/HiGHS.git
cd HiGHS
git checkout master
mkdir build 
cd build 
cmake .. 
make
make install 
pip install .. 

We’ll publish this as soon as the process is fixed for all architectures. It’s a major priority

@ZedongPeng I think they changed the directory structure.

Try pip install ..

There will be a new pip release soon, but we can not say exact timing. We need to finish some features we are currently implementing and some features we are adding to the python interface.

Hi,

I have the same error:

ImportError: dlopen(…opt/anaconda3/envs/test/lib/python3.9/site-packages/highspy/highs_bindings.cpython-39-darwin.so, 0x0002): symbol not found in flat namespace ‘__ZN5Highs10clearModelEv’

I’m using Apple M2 chip and installed highspy using pip.

We intend to keep track of such changes but at a later stage, once we have finished implementing some features.

Sorry, I don’t know when this was fixed. Keeping track of such changes is too time-consuming for us.

Just as an FYI, this problem isn’t present (for me at least) on the master branch if I compile from source - can you point me to the commit that fixed this issue on the ‘latest’ branch?

Also apologies if this is available somewhere, but what changed in the 1.5.3 release? There’s no source files on pip and I don’t see a version here on GitHub.

MacOS will use Clang to compile C++ sources, so we can use llvm-cxxfilt to find out exactly what it’s complaining about:

$ llvm-cxxfilt --strip-underscore '__ZN5Highs10clearModelEv'
Highs::clearModel()

Looks like the library on PyPI either didn’t compile Highs.cpp (unlikely) or something is not linked correctly (more likely) – might be due to how conda is handling this wheel? Try installing with pip to see if that resolves it.

If it doesn’t, as a hacky workaround, try adding the path to libhighs: sys.path.append("/Users/e3-work/opt/anaconda3/envs/nmt-pins/lib/python3.10/site-packages/highspy/.dylibs/") (also make sure there is indeed a library named libhighs.1.5.0.dylib somewhere in /Users/e3-work/opt/anaconda3/envs/nmt-pins/lib/python3.10/site-packages/highspy)