Starting with Python
Python, Anaconda, Conda,virtual environment, Spyder, experimental psychology, tutorial, installation, DevStart, developmental science
Python is one of the most popular programming languages in general. In data science, it competes with Matlab and R for first place on the podium.
In our everyday we often use python to pre-process and analyze the data. In this tutorial we will explain our preferred way of installing python and managing its libraries. There are several ways to install python, this is the one we recommend for its simplicity and flexibility.
Installing Python
Miniconda
Miniconda is our favorite way to install Python, and for good reason! While you’ve probably heard of Anaconda – that feature-packed GUI many folks use to manage Python, packages, and environments – Miniconda is its sleek, lightweight counterpart.
What makes Miniconda special? It skips all the extra GUI elements and pre-installed packages that come with Anaconda. The result? A much lighter installation that doesn’t weigh down your system! With Miniconda, you get just the essentials: Conda, Python, and a few critical dependencies. This minimal setup gives you greater control over what gets installed, keeping everything lean and efficient. Plus, it includes the default Conda package manager and channels, so you still have full access to the official Conda repository for all your package needs.
To use Miniconda download the installer from Miniconda (remember to scroll down under Anaconda)
The installation process is similar to that of Anaconda. Once the installation is complete, you will find the Anaconda Prompt among your programs. This prompt serves as your interface for installing Python packages and creating environments. To verify everything’s working properly, simply type conda
. You’ll be greeted with a comprehensive list of available conda commands ready for you to explore and use (we will see below how to do so).
To use Miniconda download the installer from Miniconda (remember to scroll down under Anaconda)
⚠️ Important
Please make sure that you select the correct version for your system!!! Select the version depending if you have Apple Silicon or an Intel processor.
Once the installation is complete, you’ll have the full power of Miniconda at your fingertips through your terminal! To verify everything’s working properly, simply open your terminal and type conda
. You’ll be greeted with a comprehensive list of available conda commands ready for you to explore and use (we will see below how to do so).
Installing python packages
To pre-process and analyze the data we will need some specific packages. It is easy to install and manage packages using conda.
It is recommended to avoid installing packages in the base environment. Instead, create dedicated environments tailored to your needs for better dependency management and a clean, organized setup.
But what are environments, and how can you manage them? Keep reading below to find out!
Open the Anaconda prompt and type conda install …
. For example, if we want to install pandas (a very useful package to handle data-frames) we would write:
conda install pandas
After thinking about for few seconds the prompt will download the package and its dependencies. Occasionally, conda may encounter difficulties locating the precise package you need. In such cases, pip, another renowned Python package manager, can come to the rescue. You might already be aware of pip
, versatility for installing and manage packages in Python.
Let’s consider I2MC, an exceptional package processing eye-tracking data. With pip, installation is a breeze. Simply use the following command:
pip install I2MC
Managing environments
Python has different versions. Sometimes when we create scripts we needs to run a specific version of python or of other packages because some of our packages may rely on older version of python or we have conflicting dependencies with other packages. Virtual environments keep these dependencies in separate “sandboxes” so you can switch between both applications easily and get them running.
One of the best features of Anaconda and Miniconda is how easily you can create and manage environments. Conda lets you create, export, list, remove, and update environments with different Python versions and packages. Let’s create an environment called working
that we’ll use for our everyday tasks and let’s make sure to have python in it. To do this, open the Anaconda Prompt and type:
conda create --name working python
Press y
when asked and after few seconds we will have out new working
environment. Now we want to tell our Anaconda prompt that we want to work on our brand new working
environment. To do so let’s write:
conda activate working
You’ll notice that the name on the left side of the command prompt has changed from base
to working
. This indicates that everything you do in the Anaconda Prompt now will apply to the working
environment.
Now we would probably want to install some packages in this new environment. Follow the tutorials above: [Installing python packages]
Installing Spyder ide
Now that we have our environment and packages set up, how can we actually use them? Sure, we could type python in the terminal and run commands there… but let’s be honest, that would be tedious and inefficient!
What we need is an IDE—and our choice is Spyder! Spyder is a powerful scientific IDE written in Python, designed specifically for scientists, engineers, and data analysts. With features like a variable explorer and integrated plotting, it’s our top pick for writing and running Python code efficiently.
If you install the full version of Anaconda, Spyder is included by default. However, Miniconda and Miniforge do not come with Spyder pre-installed. Fortunately, installing Spyder is simple!
You have two options to install Spyder:
- Standalone Installer: A ready-to-use application that doesn’t require setting up a Python environment.
- Installing as a Library: Add Spyder to your Python environment using a package manager like mamba or conda.
The standalone installer is likely the easiest approach. You can install the software once and then connect it to the Python environments of your choice.
To get started, visit the Spyder website, download the appropriate installer for your operating system, and install it on your machine.
Once installed, you can launch Spyder. Here it is in all its glory:
As mentioned earlier, you can configure Spyder to use any of the environments you’ve created. Simply click on Console, select New Console in Environment, and choose your desired environment. This means that the code you will now run into Spyder will access the python and the packages you have in the specific environment.
To properly run Spyder while connected to your environments, your environment needs to include a specific library.
Thus you need to install it by:
conda install spyder-kernels
or
pip install spyder-kernels
That’s it—now any code you run will execute within the environment you selected. Well done!
Another option is to install Spyder as a library. To do this, open the Anaconda Prompt, type the following command, and press the Enter key:
conda install -c conda-forge spyder
Remember, if you are using Miniforge, it is configured to use the Conda-Forge channel by default. This means you can simply install Spyder with the following command mamba install spyder
After thinking a bit, the Anaconda prompt will prepared a bunch of files to download and ask if you’d like to proceed. Go ahead and type “y” and hit “enter” to proceed.
It will take a while but after few seconds Spyder will be installed on your computer. To launch it you can click on the shortcut that should have appeared in your Start menu or by typing “spyder” in the Anaconda prompt.
Here it is Spyder in all its glory: