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.
Unfortunately — for reasons beyond its maintainer's control — this package has a different name on pypi (which is where pip gets its packages) than it has on conda-forge or when being imported: it's called numpy-quaternion. The easiest way is indeed to use conda, as FabienP suggested. But if you insist on using pip, you just need to follow the instructions:
python -m pip install numpy-quaternion
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With