Skip to content
Advertisement

How do I get VSCode to recognize Python3 as my default

I have python3 install on my Mac and I’m in the terminal, I use python3 by default. However when I’m in VSCode it is not recognizing python3 as my default, it’s still pulling in python2.7.

Here is a screenshot of my VScode environement: I have code-runner with python3 selected as well as my interpreter as 3.8

enter image description here

When I run my code, I get this annoying error:

Exception: Python in worker has different version 2.7 than that in driver 3.8, PySpark cannot run with different minor versions. Please check environment variables PYSPARK_PYTHON and PYSPARK_DRIVER_PYTHON are correctly set.

I have to call export PYSPARK_PYTHON=python3 to get my code to run, but I’ve already got that built in my bash.profile.

What am I missing in order to get this to run properly?

Advertisement

Answer

Add the following code in settings.json and reload the window to make the setting work:

"python.defaultInterpreterPath": "path to python3",
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement