'Can't import helper functions from module - "cannot import name ..." error

I have two scripts, a main file and a smaller module storing some helper functions. My main script opens with

from collections import namedtuple

import rospy
import serial
from sensor_msgs.msg import Imu, MagneticField

from quaternions import euler_deg2rad, euler2quat_ZYX

and in quaternions.py, I have

from collections import namedtuple
import numpy as np

def euler_deg2rad(yaw, pitch, roll):
   ....

Attempting to run the main script throws an ImportError: cannot import name 'euler_deg2rad' from 'quaternions'

What's going on here? Is importing namedtuple twice creating a circular dependency? Replacing the 'from' import in the main file with just import quaternions works fine, but I'd rather not import the whole module.



Sources

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

Source: Stack Overflow

Solution Source