Importing SciPy does not work
Question: I am trying to use SciPy to solve a very simple equation (Kepler's equation)
using Newton-Raphson. However, exectuing the program fails with the following
error message:

    
    
        return sc.optimize.newton(f, meanAnomaly, f_prime, args=(), 
    AttributeError: 'module' object has no attribute 'newton'
    

Clearly though, I have SciPy installed under Ubuntu 12.04. From scipy.test():

    
    
    NumPy version 1.5.1
    NumPy is installed in /usr/lib/python2.7/dist-packages/numpy
    SciPy version 0.9.0
    SciPy is installed in /usr/lib/python2.7/dist-packages/scipy
    Python version 2.7.2+ (default, Jan 21 2012, 23:31:34) [GCC 4.6.2]
    nose version 1.1.2
    

What is wrong? Here is my code:

    
    
    # File a
    from b import *
    
    print calculate_eccentric_anomaly(1,2)
    
    # File b
    def calculate_eccentric_anomaly(meanAnomaly, eccentricity):
        import scipy.optimize as sc
    
        def f(eccentricAnomaly):
            return (eccentricAnomaly - eccentricity * 
                    sc.sin(eccentricAnomaly) - meanAnomaly)
    
        def f_prime(eccentricAnomaly):
            return 1 - eccentricity * sc.cos(eccentricAnomaly)
    
        return sc.optimize.newton(f, meanAnomaly, f_prime, args=(), 
                                  tol=1e-10, maxiter=50)
    


Answer: You're importing `scipy.optimize` as `sc`, then you're trying to call
`sc.optimize.newton`, which would effectively be
`scipy.optimize.optimize.newton`. I would do

    
    
    import scipy.optimize as opt
    

or

    
    
    import scipy.optimize as scopt
    

