Introduction
The scope of this blog is to help the reader run Spyder with an anaconda environment on macOS in 5 minutes.
Please follow the below steps sequentially and you will be ready to code and debug your project in Spyder.
What is Spyder?
Spyder is a free and open-source scientific environment written in Python, for Python, and designed by and for scientists, engineers and data analysts.
It features a unique combination of the advanced editing, analysis, debugging, and profiling functionality of a comprehensive development tool with the data exploration, interactive execution, deep inspection, and beautiful visualization capabilities of a scientific package.
Steps to run Spyder with anaconda in 5 minutes
Run the below command to create a fresh conda environment
The name of conda environment is — spyder-env
conda create -n spyder-env
Run the below command to activate the new conda environment.
conda activate spyder-env
conda install spyder
Run the above command to install spyder
conda install pip
conda update -n base -c defaults conda
conda install spyder-kernels
pip install numpy
After installing all of the above libraries in the anaconda environment - “spyder-env”.
We need to check the anaconda python interpreter path for spyder-env so that we can activate it in the Spyder IDE. Run the below command.
which python
Click on the consoles and “Restart Kernel” . The Restart Kernel will help you to switch to the new anaconda environment.
In the console window type the below commands to verify if you are working in the (spyder-env) anaconda environment.
import os
print (os.environ['CONDA_DEFAULT_ENV'])
This is how you can include any anaconda or virtual environments in Spyder quickly.
How to open an existing project in Spyder?
How to run your first python script on Spyder?
Unlike any other IDE the command “python filename.py” will not run the file in Spyder.
You need to type the command “run filename.py” to run your python scripts.
Shortcut keys for commenting out lines of Python code in Spyder
- Single line comment — Command + 1
- Multi-line comment select the lines to be commented — Command + 4
- Unblock Multi-line comment — Command + 5
How to change the theme of Spyder from dark to bright
Follow the below steps, click in sequence:
Spyder — — — — -> Preferences — — — ->Appearence
Make sure to choose the combination mentioned in the above image to change the background color or theme of Spyder.
Enjoy coding!
Conclusion:
The scope of this blog is to document steps one can follow to get started with the IDE Spyder with anaconda. Also, I do not want to invest time in the future setting this up on a machine thus a short blog.
Switching IDE’s is time taking and if this is the demand of a new project consider this as an opportunity to learn something new. It took me 2 hours to get this started as there are multiple ways of doing the same thing and one must find the simplest and sustainable way and also the one that is intuitive when it comes to GUI.
Wrote a short blog to stay motivated and not go back to coding in the terminal, Wish me luck with this IDE.
If you find this blog helpful please give a clap, share it with the team who might need this basic yet important blog.
Feel free to subscribe to my page for more Data Science related blogs.