How to Setup Data Science Environment The Ultimate Guide: Essentials, Tips and Tricks. (VS Code, Conda, Extensions)

How to Setup Data Science Environment The Ultimate Guide: Essentials, Tips and Tricks. (VS Code, Conda, Extensions)

A Comprehensive Setup Guide for VS Code for Data Science

Overview of Python Environment Management Tools

Choosing the right tool for managing Python environments can feel like deciding whether you should cook a five-course meal from scratch or just microwave some leftovers. Luckily, you’ve got options: Anaconda, Miniconda, and Pipenv—each with their own quirks and strengths. Let's dive in and find out which one will make your coding life easier (or at least slightly less painful).

Anaconda

Imagine Anaconda as the all-inclusive vacation package of Python environments. It comes with everything you need—conda for package management, an environment manager, and a buffet of pre-installed libraries. No need to think about what to install next; Anaconda's already got your back with a massive library lineup.

Who should use it?

  • Library hoarders: If you need 50+ libraries pre-installed, and would rather not pick them out individually.

  • Beginners: People who prefer software that holds your hand while whispering, “It’s okay, I’ve got this.”

  • Data science enthusiasts: If your idea of fun is tinkering with machine learning models and running statistical analyses, Anaconda is probably already your best friend.

Miniconda

Miniconda is Anaconda’s cooler, minimalist sibling. It ditches the bloated packages and lets you install only what you need. Think of it as walking into a fancy restaurant but only ordering a salad. You still get the power of conda without the “I didn’t ask for this” feeling.

Who should use it?

  • Minimalists: If the idea of carrying around unnecessary baggage gives you hives, Miniconda is your sanctuary.

  • Control freaks: Those who like to fine-tune and micromanage their environments with laser precision. and want to utilize the storage space for better good.

  • Developers: When your job involves juggling multiple environments like a circus act, Miniconda helps you keep them light and manageable.

Pipenv

Ah, Pipenv, the love child of pip and virtualenv, here to make dependency management slightly less chaotic. It automatically sets up virtual environments and handles your dependencies like a pro (well, at least like an intern who’s really trying hard to impress you). Pipenv also adds a handy Pipfile for tracking your project's dependencies—so you can actually figure out what’s going on when something inevitably breaks.

Who should use it?

  • Simplicity seekers: Developers who prefer the ease of pip but want a little more structure in their lives.

  • Dependency dodgers: If you like having one tool manage both your virtual environments and dependencies without much fuss.

  • Small project aficionados: Perfect for projects where you don’t need to summon an army of packages to get the job done.


Summary Table: Choosing Your Tool Like a Pro

ToolDescriptionBest For
AnacondaFull-featured distribution with every library you never knew you neededData science lovers, beginners, anyone who wants the whole package
MinicondaMinimal installer, lets you add only what you needEnvironment purists, customization fans, devs who like things lightweight
PipenvCombines package and virtual environment managementPeople who like life easy and simple, smaller projects

How to install Anaconda

follow this link: anaconda.com/download/success

How to Install Miniconda

follow this link: https://docs.anaconda.com/miniconda/

Note: I personally prefer Miniconda because it lets us use the best of both worlds lightweight and works exactly like Anaconda without dedicating much disk space.

Why VS Code?

Now that you’ve chosen your Python environment tool, let’s talk about the editor that will make your life infinitely better—or at least marginally more pleasant: Visual Studio Code (VS Code). Think of it as the Swiss Army knife of text editors—free, open-source, and cross-platform, which means you can run it on Windows, macOS, or Linux without feeling guilty about selling your soul to any one OS.

Why the Hype?

  • Free! (Because who doesn’t love free stuff?)

  • Integrated Git support, so you can pretend you understand version control.

  • Lightweight and fast, unlike traditional bloated IDEs that make your laptop sound like it’s preparing for takeoff.

  • Support for Jupyter Notebooks (because who doesn’t love running code one line at a time to troubleshoot… everything?).

How to Install VS Code

Just go to the official website, download the installer, and pretend it’s not going to ask you a dozen questions about where you want things installed. Once you're through that, you’re golden.

Setting Up the Default Terminal in VS Code

For some reason, VS Code doesn’t know which terminal you prefer. Here’s how to tell it:

  1. Hit Ctrl + Shift + P (or Cmd + Shift + P on macOS).

  2. Search for Terminal: Select Default Profile, and choose your preferred shell (Bash, Command Prompt, PowerShell, whatever floats your boat).

  3. Next time you open the terminal (Ctrl + `), voilà! Your shell of choice appears, ready to serve.

Setting Up Jupyter Notebooks in VS Code

Need to run Jupyter Notebooks but hate switching between applications? VS Code has your back.

  1. Install the Jupyter extension from the VS Code marketplace.

  2. Open a .ipynb file directly in VS Code, and it will transform into a sleek Jupyter interface without breaking a sweat.

Essential VS Code Extensions

Let’s be honest—VS Code is great out of the box, but with the right extensions, it’s phenomenal.

  1. Tabnine: AI Chat & Autocomplete for JavaScript, Python, Typescript, Java, PHP, Go, and more: the AI assistant that boosts productivity by automating repetitive tasks and providing context-aware suggestions tailored to your style. Enjoy unparalleled privacy and control, as your code remains secure and never shared without permission. With its personalized approach, Tabnine helps developers of all levels enhance code quality and consistency, making software development more efficient and enjoyable.

  2. Black Formatter: Love your code, but hate formatting it? Black will whip your code into shape faster than a drill sergeant at boot camp.

Some Configurations changes for Black that I prefer

To change the default line length to 120 characters in VS Code, you'll need to adjust the settings for Python linting or formatting tools (like Black or Pylint). Here's how you can do it for Black:

  1. Open Settings in VS Code by pressing Ctrl + , (or Cmd + , on macOS).

  2. Search for "Python formatting black args" in the search bar.

  3. Click Edit in settings.json to modify the settings.json file directly.

  4. Add the following line to set the max line length to 120:

"python.formatting.blackArgs": ["--line-length", "120"]

Next time you format your code using Black, it will follow the 120-line length limit, so you can finally wave goodbye to those endlessly wrapped lines.

Customizations in VS Code

Lastly, let’s talk about customizations. You can tweak VS Code to your heart’s content—from themes to font sizes. Personally, after years in dark mode, I’ve made the scandalous switch to light mode.

Why the switch?

  • Better visibility: In bright rooms, light mode actually works. Who knew?

  • Refreshing change: It’s like repainting your room but with way less effort.

  • Focus boost: Maybe it’s the extra brightness, but somehow it helps me focus. (Or it’s just a placebo, but who’s judging?)


If you've ever spent an hour perfecting your VS Code setup only to lose it when switching devices, Settings Sync is here to save the day. With this feature, you can easily synchronize your settings, extensions, keyboard shortcuts, themes, and more across multiple devices. No more manually reconfiguring everything when you move from your laptop to your desktop or another machine.

Here’s how to set it up:

1. Enable Settings Sync

  • Open VS Code and press Ctrl + Shift + P (or Cmd + Shift + P on macOS) to bring up the Command Palette.

  • Type Preferences: Settings Sync: Trun On and select it from the list.

  • You'll be prompted to sign in with either a GitHub or Microsoft account. Pick your preferred poison (both work just fine).

2. Choose What to Sync

Once you're logged in, you can choose which settings to sync:

  • Settings: Sync your workspace configurations like font size, theme, and editor layout.

  • Extensions: Bring all your beloved extensions to any device.

  • Keybindings: Your custom keyboard shortcuts will follow you wherever you go.

  • Snippets: Yes, even your personalized snippets can be synced.

  • UI State: This includes the layout of your VS Code window, open folders, and working files.

You can fine-tune what you sync by going to Settings > Settings Sync and toggling the items you want.

3. Sync Settings Across Devices

Once you've turned on Settings Sync on one device, all you need to do on any other machine is:

  • Open VS Code and repeat the Ctrl + Shift + P (or Cmd + Shift + P) step.

  • Type Turn on Settings Sync and sign in with the same account.

  • Voilà! Your settings, extensions, and even your precious dark/light theme will be imported in a matter of seconds

In conclusion, whether you’re deep in the data science trenches with Anaconda, cruising light with Miniconda, or keeping it simple with Pipenv, your Python environment setup and workflow will thank you. And with VS Code, you'll have all the tools you need to actually enjoy coding—well, as much as one can enjoy debugging.

Cheers Until Next Time !!

Did you find this article valuable?

Support Shreyas Kulkarni by becoming a sponsor. Any amount is appreciated!