title: Spark Installation and Configuration on MacOS ImportError: No module named pyspark
body: <p>I'm trying to configure apache-spark on MacOS. All the online guides ask to either download the spark tar and set up some env variables or to use <code>brew install apache-spark</code> and then setup some env variables.</p>
  
  <p>Now I installed apache-spark using <code>brew install apache-spark</code>.
  I run <code>pyspark</code> in terminal and I am getting a python prompt which suggests that the installation was successful.</p>
  
  <p>Now when I try to do <code>import pyspark</code> into my python file, I'm facing error saying <code>ImportError: No module named pyspark</code></p>
  
  <p>The strangest thing I'm not able to understand is how is it able to start an REPL of pyspark and not able to import the module into python code.</p>
  
  <p>I also tried doing <code>pip install pyspark</code> but it does not recognize the module either.</p>
  
  <p>In addition to installing apache-spark with homebrew, I've set up following env variables.</p>
  
  <pre><code>if which java &gt; /dev/null; then export JAVA_HOME=$(/usr/libexec/java_home); fi
  
  if which pyspark &gt; /dev/null; then
    export SPARK_HOME="/usr/local/Cellar/apache-spark/2.1.0/libexec/"
    export PYSPARK_SUBMIT_ARGS="--master local[2]"
  fi
  </code></pre>
  
  <p>Please suggest what exactly is missing on my setup to run pyspark code on my local machine.</p>