Search code examples
pythonimportmodulequaternions

How to fix "No module named 'quaternion'" in Python?


I am trying to import the module quaternion into my code to be able to rotate my sensor data. I keep getting the error, 'No module named 'quaternion''.

To install the quaternion module to my computer I used my command prompt and typed

> conda activate base
> pip install quaternion

When I run

import quaternion

this is the output:

(base) C:\Users\erapp\Code>C:/Users/erapp/Anaconda3/python.exe c:/Users/erapp/Code/mbl_mc10/code/sensor_prep_utils.py
Traceback (most recent call last):
  File "c:/Users/erapp/Code/mbl_mc10/code/sensor_prep_utils.py", line 1, in <module>
    import quaternion
ModuleNotFoundError: No module named 'quaternion'

Any help would be greatly appreciated.


Solution

  • You should solve this by installing the conda package for quaternion (available from conda-forge) with conda install -c conda-forge quaternion

    In your case it looks like you're not using pip from your conda environment, which results in installing the package outside this environment. (test with which pip)

    If you're interested, here are some guidelines on using pip with conda, and future evolutions on interoperability between the two.