Ubuntu 20.04安装SALOME-9.8报错:No module named '_omnipy'求助
Hey there, this error is super common when SALOME's bundled dependencies clash with system-wide or Anaconda-managed Python environments. Let's break down why this happens and how to fix it step by step:
Why this happens
SALOME 9.8 ships with its own version of Python, omniORB, and other critical libraries. When Anaconda is installed, it modifies your PATH and PYTHONPATH environment variables to prioritize its own Python interpreter. This means SALOME tries to use Anaconda's Python instead of its bundled one, and Anaconda's Python can't find the private _omnipy module that comes with SALOME's omniORB.
Solutions to try
1. Temporarily disable Anaconda before launching SALOME
This is the quickest test to confirm if Anaconda is the culprit. Open a new terminal and run these commands:
# Unset Anaconda-related environment variables unset PYTHONPATH unset CONDA_PREFIX # Refresh your shell config (use ~/.zshrc if you're on Zsh) source ~/.bashrc # Navigate to your SALOME installation directory cd /home/$USER/Downloads/SALOME-9.8.0-native-UB20.04-SRC/BINARIES-UB20.04/SALOME # Launch SALOME ./salome
2. Force SALOME to use its bundled Python
If the first method works, you can directly call SALOME's own Python interpreter to avoid environment conflicts:
# Replace the paths with your actual SALOME installation paths /home/$USER/Downloads/SALOME-9.8.0-native-UB20.04-SRC/BINARIES-UB20.04/Python/bin/python3.8 \ /home/$USER/Downloads/SALOME-9.8.0-native-UB20.04-SRC/BINARIES-UB20.04/SALOME/bin/salome/salome
3. Ensure SALOME's library paths are prioritized
The _omnipy module is a C extension that needs access to SALOME's omniORB libraries. Set the LD_LIBRARY_PATH before launching:
export LD_LIBRARY_PATH=/home/$USER/Downloads/SALOME-9.8.0-native-UB20.04-SRC/BINARIES-UB20.04/omniORB/lib:$LD_LIBRARY_PATH # Now launch SALOME cd /path/to/your/SALOME/SALOME ./salome
4. Permanently modify the SALOME startup script
To avoid running these commands every time, edit the SALOME startup script to isolate its environment:
- Open the
salomescript in your SALOME directory with a text editor:nano /home/$USER/Downloads/SALOME-9.8.0-native-UB20.04-SRC/BINARIES-UB20.04/SALOME/salome - Add these lines at the very top of the script:
# Isolate from Anaconda environment unset PYTHONPATH unset CONDA_PREFIX # Set SALOME's library path SALOME_ROOT="/home/$USER/Downloads/SALOME-9.8.0-native-UB20.04-SRC/BINARIES-UB20.04" export LD_LIBRARY_PATH="$SALOME_ROOT/omniORB/lib:$LD_LIBRARY_PATH" # Prioritize SALOME's bundled Python export PATH="$SALOME_ROOT/Python/bin:$PATH" - Save the file and close it. Now you can launch SALOME normally with
./salomewithout environment conflicts.
内容的提问来源于stack exchange,提问作者CHEN Duanwu

