E0401:Unable to import 'pyspark in VSCode in Windows 10 - apache-spark

I have installed below on my windows 10 machine to use the Apache Spark.
Java,
Python 3.6 and
Spark (spark-2.3.1-bin-hadoop2.7)
I am trying to write pyspark related code in VSCode. It is showing red underline under the 'from ' and showing error message
E0401:Unable to import 'pyspark'
I have also used ctrl+Shift+P and select "Python:Update workspace Pyspark libraries". It is showing notification message
Make sure you have SPARK_HOME environment variable set to the root path of the local spark installation!
What is wrong?

You will need to install the pyspark Python package using pip install pyspark. Actually, this is the only package you'll need for VSCode, unless you also want to run your Spark application on the same machine.

Related

pyspark to open directly in jupyter-lab

Installed below apps on windows 10
Install apache spark 3.1.3
Installed Hadoop 3.3.2
Installed Jupyter-lab
When i execute pyspark or spark-shell from command line. I get the below output which mean apache spark got installed/configured correctly
When in execute pyspark from command line, i want jupyter-lab interface to be opened automatically.
When i set the below environment variable jupyter notebook opens automatically
PYSPARK_DRIVER = C:\Users\xxxx\AppData\Local\Programs\Python\Python39\Scripts\jupyter.exe
PYSPARK_DRIVER_PYTHON_OPTS = notebook
I tried below setting, but no luck
PYSPARK_DRIVER = C:\Users\xxxx\AppData\Local\Programs\Python\Python39\Scripts\jupyter-lab.exe
PYSPARK_DRIVER_PYTHON_OPTS = lab
What environment variables, i need to set in order to open jupyter-lab directly. How to specify the kernel in jupyter kernels ?

Jupyter Notebook and pandas installation?

currently i am doing course on Data Science on coursera but i dont know how to install jupyter notebook environment as well as pandas library can anyone show me how it is done?
For fulfilling above requirement please install Anaconda(data science toolkit) in you system which comes with all the packages/modules which includes Pandas,Numpy and Jupyter notebook.
Anaconda comes with follow packages check out the link
Anaconda Download Link
How to install Video Guide link
I recommend you download & install Anaconda Navigator
Once you install & launch it, you can then download Jupyter notebook from the dashboard of anaconda navigator
If you want to create a new environment, say new_env, then there is an option for creating a new environment aswell. Just select if you want to use Python or R, and which version you want and a new environment is created
Assuming you are using windows, search for Anaconda Prompt from the windows start and activate the new_env by doing: activate new_env
When the new_env is activated, just follow the instructions here for installing pandas
You can also check this like out: Installing Jupyter Notebook

Can PySpark work without Spark?

I have installed PySpark standalone/locally (on Windows) using
pip install pyspark
I was a bit surprised I can already run pyspark in command line or use it in Jupyter Notebooks and that it does not need a proper Spark installation (e.g. I did not have to do most of the steps in this tutorial https://medium.com/#GalarnykMichael/install-spark-on-windows-pyspark-4498a5d8d66c ).
Most of the tutorials that I run into say one needs to "install Spark before installing PySpark". That would agree with my view of PySpark being basically a wrapper over Spark. But maybe I am wrong here - can someone explain:
what is the exact connection between these two technologies?
why is installing PySpark enough to make it run? Does it actually install Spark under the hood? If yes, where?
if you install only PySpark, is there something you miss (e.g. I cannot find the sbin folder which contains e.g. script to start history server)
As of v2.2, executing pip install pyspark will install Spark.
If you're going to use Pyspark it's clearly the simplest way to get started.
On my system Spark is installed inside my virtual environment (miniconda) at lib/python3.6/site-packages/pyspark/jars
PySpark installed by pip is a subfolder of full Spark. you can find most of PySpark python file in spark-3.0.0-bin-hadoop3.2/python/pyspark. so if you'd like to use java or scala interface, and deploy distribute system with hadoop, you must download full Spark from Apache Spark and install it.
PySpark has a Spark installation installed. If installed through pip3, you can find it with pip3 show pyspark. Ex. for me it is at ~/.local/lib/python3.8/site-packages/pyspark.
This is a standalone configuration so it can't be used for managing clusters like a full Spark installation.

how to setup pyspark with zeppelin on windows 10

I have had difficulties installing Zeppelin 0.7.2
Using the Zeppelin version 0.7.2 of spark that comes with it, I can run spark code, but I am unable to run %pyspark code even after modifying python environment variables to point to where python is installed (python was installed using anaconda).
%python code works fine.
If anyone can help resolve this issue I would be grateful. (The odd thing is I have done the same installation on another windows 10 laptop and pyspark does execute.)
The error I get is that: pyspark is not responding

Pyspark + Hadoop + Anaconda install

I'm new to Anaconda, Spark and Hadoop. I wanted to get a standalone dev environment setup on my Ubuntu 16.04 machine but was getting confused on what I do within conda and what is external.
So far I had installed Anaconda and created a Tensorflow environment (I will be using TF too I should add), and installed PySpark separately outside of Anaconda.
However I wasn't sure if that's what I'm supposed to do or whether I am supposed to use conda install? I'm also eventually going to want to install Hortonwork's Hadoop too - and hear that may already come bundled with spark.
Long story short - I just want to get a dev environment set up with all these technologies that I can play around with and have data flow from one to the other as seamlessly as possible.
Appreciate any advice on the "correct" way to set everything up.

Resources