title: Why am I getting a no attribute error in my python script but not in my python interpreter?
body: <p>I'm trying to write a program that edits a video using the moviepy module in python. I have this</p>
  
  <pre><code>#!/usr/bin/env python
  
  import os
  import math
  import moviepy as mp
  import mediainfo
  
  class Editor:
  
      OFFSET = 2 #seconds
  
  
      def __init__(self, identified_frames, options, *args, **kwargs):
          self.movie_path = options.video_path
          self.video = mp.editor.VideoFileClip(self.movie_path)
          #Get the FPS of the input movie and round the number up
          self.movie_fps = math.ceil(mediainfo.get_fps(self.movie_fps))
  ...
  </code></pre>
  
  <p>but for some reason this throws this error:</p>
  
  <pre><code>Traceback (most recent call last):
    File "editor.py", line 179, in &lt;module&gt;
      editor = Editor(args["video"], options)
    File "editor.py", line 16, in __init__
      self.video = mp.editor.VideoFileClip(self.movie_path)
  AttributeError: 'module' object has no attribute 'editor'
  </code></pre>
  
  <p>which is strange because according to <a href="https://zulko.github.io/moviepy/examples/ukulele_concerto.html" rel="nofollow noreferrer">this</a> documentation definitely exists. What is even weirder is that when I open up my python interpreter, I can do this with no problem: </p>
  
  <pre><code>In [1]: import moviepy
  
  In [2]: import moviepy.editor
  
  In [3]: import moviepy as mp
  
  In [4]: mp.editor
  Out[4]: &lt;module 'moviepy.editor' from '/usr/local/lib/python2.7/site-packages/moviepy/editor.pyc'&gt;
  
  In [5]: mp.editor.VideoFileClip
  Out[5]: &lt;class moviepy.video.io.VideoFileClip.VideoFileClip at 0x1046bca10&gt;
  </code></pre>
  
  <p>So the  <code>moviepy</code> module definitely contains <code>editor.VideoFileClip</code>. What would cause this error to be thrown in my program if it works in my interpreter? Do I have some environment variables set wrong or something? Any help would be greatly appreciated. </p>
  
  <p>This is what I've done:
  I have python2 and python3 installed installed but made sure both the interpreter and the program were being run with python2. I also tried reinstalling moviepy but that didn't do anything. I also went and looked through the source code to make sure that the function actually existed (it does).</p>
  
  <p>Update:</p>
  
  <p>This is a duplicate of <a href="https://stackoverflow.com/questions/8696322/why-does-this-attributeerror-in-python-occur">this</a> question. The best answer says</p>
  
  <blockquote>
    <p>This happens because the scipy module doesn't have any attribute named
    sparse. That attribute only gets defined when you import scipy.sparse.</p>
    
    <p>Submodules don't automatically get imported when you just import
    scipy; you need to import them explicitly. The same holds for most
    packages, although a package can choose to import its own submodules
    if it wants to. (For example, if scipy/<strong>init</strong>.py included a
    statement import scipy.sparse, then the sparse submodule would be
    imported whenever you import scipy.)</p>
  </blockquote>
  
  <p>Which leads me to change my question to why does python work this way? Is there a benefit?</p>