I used Spark 2.2 and hadoop 2.7.
- Extract and move Spark in C:/ (or where you want in your computer)
- Move the winutils.exe in C:/Hadoop/bin/
- Set the SPARK_HOME and HADOOP_HOME :
SPARK_HOME = "C:/C:\spark-YOUR_VERSION"
HADOOP_HOME = "C:\winutils"
Because this doesn't work on my Windows, I added the following lines in my conftest.py
os.environ["SPARK_HOME"]="C:\spark-2.2.0-bin-hadoop2.7"
os.environ["HADOOP_HOME"]="C:\winutils"
pip install pytest
pip install pyspark
In the links bellow, you can find different configuration for pytest to launch the spark context :
You also can use mine in the src folder that have the environment variables set.
The conftest.py should be in the folder of your test files.
To run a test in a console :
pytest main_test.py
To run a test from IntelliJ :
Setting -> Python Interpreted Tools -> change "run test" to py.test
Then you can run your test file as a normal python file.
Find a way to hide WARNINGS