eclipse-sumo / sumo

Eclipse SUMO is an open source, highly portable, microscopic and continuous traffic simulation package designed to handle large networks. It allows for intermodal simulation including pedestrians and comes with a large set of tools for scenario creation.
https://eclipse.dev/sumo
Eclipse Public License 2.0
2.57k stars 1.43k forks source link

libxerces-c-3.2.dylib not loaded #14493

Closed RaffaeleTranfaglia closed 8 months ago

RaffaeleTranfaglia commented 8 months ago

Hello, I am having problems in executing sumo on a MacOs Sonoma system. In particular I built SUMO from the source code. The issue is that it cannot find the libxerces-c-3.2.dylib library in my system.

example instruction: sumo --version output:
dyld[49021]: Library not loaded: /usr/local/opt/xerces-c/lib/libxerces-c-3.2.dylib Referenced from: <99626E3D-D569-3738-B519-E009C815DA9F> /Users/raffaele/sumo_binaries/bin/sumo Reason: tried: '/usr/local/opt/xerces-c/lib/libxerces-c-3.2.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/usr/local/opt/xerces-c/lib/libxerces-c-3.2.dylib' (no such file), '/usr/local/opt/xerces-c/lib/libxerces-c-3.2.dylib' (no such file), '/usr/local/lib/libxerces-c-3.2.dylib' (no such file), '/usr/lib/libxerces-c-3.2.dylib' (no such file, not in dyld cache) [1] 49021 abort sumo --version

I have installed xerces-c with homebrew, accordingly the libxerces-c-3.2.dylib library is locate in /opt/homebrew/lib. The problem is that SUMO does not look in that directory when it needs the library.

I hope I have been clear in depicting the problem.

RobertHilbrich commented 8 months ago

Hi, yes, brew sometimes updates the library versions of slightly moves the directories. If you have built sumo from the sources and did a brew upgrade afterwards, chances are that the library name or path has changed. Please do another brew upgrade and re-build sumo from the sources. Also, don't forget to remove the build folder, since cmake would have cached the previous location of libxerces.

RaffaeleTranfaglia commented 8 months ago

Should I also remove the brew packages before the upgrade? For example should I remove xerces-c before the brew upgrade?

This is the script I use to build sumo:

!/bin/bash

echo "Installing system dependencies for SUMO"

Quick check that we actually have brew, if not, lets install it

command -v brew >/dev/null 2>&1 || echo >&2 "Homebrew is missing, you can install it by running \n/usr/bin/ruby -e \$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" || exit 1

script dependencies

brew install wget

rllab dependencies

brew install swig sdl sdl_image sdl_mixer sdl_ttf portmidi

sumo dependencies

brew install Caskroom/cask/xquartz autoconf automake pkg-config libtool gdal proj xerces-c fox

echo "Installing sumo binaries" mkdir -p $HOME/sumo_binaries/bin pushd $HOME/sumo_binaries/bin wget https://akreidieh.s3.amazonaws.com/sumo/flow-0.4.0/binaries-mac.tar.xz tar -xf binaries-mac.tar.xz rm binaries-mac.tar.xz chmod +x * popd export SUMO_HOME="$HOME/sumo_binaries/bin" export PATH="$SUMO_HOME:$PATH"

echo 'Add the following to your ~/.bashrc:' echo '' echo 'export SUMO_HOME="$HOME/sumo_binaries/bin"' echo 'export PATH="$SUMO_HOME:$PATH"'

For build folder, do you mean /sumo_binaries/bin? Thank you in advance for your help.

temetski commented 8 months ago

@RaffaeleTranfaglia Are you getting these sumo binaries from the flow-project? If so there are not being built from source, but have been precompiled by them.

Would a pip install work in this case for your python environment?

pip install eclipse-sumo
RaffaeleTranfaglia commented 8 months ago

Yes, I am trying to install flow-project. You are correct, the sumo version is pre-compiled. So should I not run the script above and simply do pip install eclipse-sumo?

temetski commented 8 months ago

Either you build sumo from the source code yourself, or if you do not need any modifications of the source code, I find pip-installing sumo works on my mac (Apple silicon, sonoma). The only possible issue is that if you are using an Intel mac on sonoma, there are no pip wheels of sumo for this.

RaffaeleTranfaglia commented 8 months ago

I am currently using a MacOs Sonoma M2. Do flow and sumo work in your system using pip? In the official flow website it is specified that Flow is not currently compatible with the most up-to-date version of SUMO.

temetski commented 8 months ago

I have worked with the flow-project in the past, but not at the moment. flow has not been updated in a very long time (it points to 2147d155b1 which is sumo 1.1.0), but since it uses traci to interface with SUMO, you could possibly patch up any deprecated api calls you may find.

RaffaeleTranfaglia commented 8 months ago

I installed sumo using pip, when I execute sumo --version it gives the following output: dyld[11391]: Library not loaded: /opt/homebrew/opt/libtiff/lib/libtiff.5.dylib Referenced from: <17847387-7133-36F8-BE42-C23E7E9B7E82> /opt/miniconda3/envs/flow/lib/python3.9/site-packages/sumo/bin/sumo Reason: tried: '/opt/homebrew/opt/libtiff/lib/libtiff.5.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/opt/homebrew/opt/libtiff/lib/libtiff.5.dylib' (no such file), '/opt/homebrew/opt/libtiff/lib/libtiff.5.dylib' (no such file), '/opt/homebrew/Cellar/libtiff/4.6.0/lib/libtiff.5.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/opt/homebrew/Cellar/libtiff/4.6.0/lib/libtiff.5.dylib' (no such file), '/opt/homebrew/Cellar/libtiff/4.6.0/lib/libtiff.5.dylib' (no such file)

It searches for libtiff.5.dylib file, but in those directories there is libtiff.6.dylib. My version of libtiff is 4.6.0 (latest stable version) should I try to install an older version?

RaffaeleTranfaglia commented 8 months ago

I kind of solved the installation problems installing sumo using brew. I couldn't know if it will work but at least now I can execute sumo --version and sumo-gui commands. When I try to test if flow and sumo work together running the test python script python examples/simulate.py ring it raises this error.

Traceback (most recent call last):
  File "/Users/raffaele/Development/AutonomousVehicles/flow/examples/simulate.py", line 90, in <module>
    exp = Experiment(flow_params, callables)
  File "/Users/raffaele/Development/AutonomousVehicles/flow/flow/core/experiment.py", line 76, in __init__
    create_env, _ = make_create_env(flow_params)
  File "/Users/raffaele/Development/AutonomousVehicles/flow/flow/utils/registry.py", line 71, in make_create_env
    all_envs = gym.envs.registry.all()
AttributeError: 'dict' object has no attribute 'all'

It seems that is something regarding flow, so I suppose the original problem is solved. Thank you to everyone for the great help.

RobertHilbrich commented 8 months ago

Alright - yes, seems like a python issue in flow. I am glad, that SUMO is now working for you.