Why can Python not recognize spark when I import?
Question: Python spits out an error when I try to import spark:

    
    
    import pyspark.context
    

And the error is

    
    
    Traceback (most recent call last):
      File "<pyshell#N>", line 1, in <module>
        import pyspark.context
    ImportError: No module named pyspark.context
    

I have added the following to my `.bashrc` file, and I re-ran the terminal,
too:

    
    
    export SPARK_HOME="/Users/<username>/Downloads/spark-1.4.0"
    export PYTHONPATH=$SPARK_HOME/python/:$PYTHONPATH
    

The path to `SPARK_HOME` is the path preceding `/bin/pyspark`, and it contains
the folder `python`, as it should.

My `PYTHONPATH` seems correct however, since I can import `numpy` and such.
What could be the problem?


Answer: Try load pyspark programmatically:

    
    
    import sys
    try:
        sys.path.append("/Users/<username>/Downloads/spark-1.4.0/python/")
        from pyspark import context
        print ("Successfully imported Spark Modules")
    except ImportError as e:
        print ("Can not import Spark Modules", e)
    

