'Numpy issue for racecar simulator: No module named 'numpy.core._multiarray_umath'

I am taking a course that uses a racecar simulator and I need to run some pre-built code that uses a custom library and also numpy. When I try to run the code on Ubuntu I get the following error:

Traceback (most recent call last):
  File "/mnt/c/Users/seb/documents/Racecar/racecar-seb-h-s/labs/../library/numpy/core/__init__.py", line 22, in <module>
    from . import multiarray
  File "/mnt/c/Users/seb/documents/Racecar/racecar-seb-h-s/labs/../library/numpy/core/multiarray.py", line 12, in <module>
    from . import overrides
  File "/mnt/c/Users/seb/documents/Racecar/racecar-seb-h-s/labs/../library/numpy/core/overrides.py", line 7, in <module>
    from numpy.core._multiarray_umath import (
ModuleNotFoundError: No module named 'numpy.core._multiarray_umath'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "demo.py", line 16, in <module>
    import racecar_core
  File "/mnt/c/Users/seb/documents/Racecar/racecar-seb-h-s/labs/../library/racecar_core.py", line 13, in <module>
    import camera
  File "/mnt/c/Users/seb/documents/Racecar/racecar-seb-h-s/labs/../library/camera.py", line 11, in <module>
    import numpy as np
  File "/mnt/c/Users/seb/documents/Racecar/racecar-seb-h-s/labs/../library/numpy/__init__.py", line 150, in <module>
    from . import core
  File "/mnt/c/Users/seb/documents/Racecar/racecar-seb-h-s/labs/../library/numpy/core/__init__.py", line 48, in <module>
    raise ImportError(msg)
ImportError:

IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!

Importing the numpy C-extensions failed. This error can happen for
many reasons, often due to issues with your setup or how NumPy was
installed.


We have compiled some common reasons and troubleshooting tips at:

    https://numpy.org/devdocs/user/troubleshooting-importerror.html

Please note and check the following:

  * The Python version is: Python3.8 from "/usr/bin/python3"
  * The NumPy version is: "1.21.2"

and make sure that they are the versions you expect.
Please carefully study the documentation linked above for further help.

Original error was: No module named 'numpy.core._multiarray_umath'

I have tried all the other potential duplicates that I could find and used the link but none worked. I have also tried uninstalling and reinstalling and updating numpy to no avail.

The output of running the command echo $PATH was the following:

/home/seb/.local/bin
:/usr/local/sbin
:/usr/local/bin
:/usr/sbin
:/usr/bin
:/sbin
:/bin
:/usr/games
:/usr/local/games
:/mnt/c/Program Files/WindowsApps/CanonicalGroupLimited.UbuntuonWindows_2004.2021.825.0_x64__79rhkp1fndgsc:/mnt/c/Program Files/Java/jdk-13.0.1/bin.
:/mnt/c/Program Files (x86)/Common Files/Oracle/Java/javapath
:/mnt/c/Program Files (x86)/Common Files/Intel/Shared Libraries/redist/intel64/compiler:/mnt/c/WINDOWS/system32
:/mnt/c/WINDOWS
:/mnt/c/WINDOWS/System32/Wbem
:/mnt/c/WINDOWS/System32/WindowsPowerShell/v1.0/
:/mnt/c/WINDOWS/System32/OpenSSH/
:/mnt/c/Users/seb/anaconda3
:/mnt/c/Users/seb/anaconda3/Library/mingw-w64/bin
:/mnt/c/Users/seb/anaconda3/Library/usr/bin
:/mnt/c/Users/seb/anaconda3/Library/bin
:/mnt/c/Users/seb/anaconda3/Scripts
:/mnt/c/Users/seb/AppData/Local/Microsoft/WindowsApps
:/snap/bin

The output of running the command python3 -m site was the following:

sys.path = [
    '/mnt/c/Users/seb/documents/Racecar/racecar-seb-h-s/labs',
    '/usr/lib/python38.zip',
    '/usr/lib/python3.8',
    '/usr/lib/python3.8/lib-dynload',
    '/home/seb/.local/lib/python3.8/site-packages',
    '/usr/local/lib/python3.8/dist-packages',
    '/usr/lib/python3/dist-packages',
]
USER_BASE: '/home/seb/.local' (exists)
USER_SITE: '/home/seb/.local/lib/python3.8/site-packages' (exists)
ENABLE_USER_SITE: True


Solution 1:[1]

This has happened to me as well because I am taking the same course. I solved it by uninstalling all the libraries and installing them again. Here is the link to the setup instructions: https://mitll-racecar-mn.readthedocs.io/en/latest/gettingStarted/computerSetup/python.html. These are the commands you have to run to install the libraries: sudo apt update sudo apt install python3.8 sudo apt install python3-pip

pip3 install --upgrade pip
pip3 install numpy
pip3 install matplotlib
pip3 install mypy
pip3 install nptyping
pip3 install opencv-contrib-python

pip3 install jupyter
pip3 install ipywidgets
jupyter nbextension enable --py widgetsnbextension

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 konfrag