DEV Community

obonyodorice
obonyodorice

Posted on

My Journey to a Seamless Python Dev Environment (and How You Can Too!) Author:"DevDorice"


Introduction

Hey everyone! I recently went through the process of setting up my Python development environment, and honestly, it can feel a bit overwhelming with all the tools out there. But I've found a flow that really works for me, integrating Git, Docker, WSL (since I'm on Windows), and a super-smooth SSH connection to GitHub. I want to share exactly how I did it, step-by-step, so you can set up your own efficient workspace too!.

Prerequisites
Before we dive in, here's what you'll need:

- A Computer:

Running Windows 10 or higher (for WSL instructions) or a macOS/Linux distribution

- An Internet Connection:

To download the necessary software.

- Basic Computer Skills:

Familiarity with navigating your operating system and using a terminal or command prompt.

- A GitHub Account (Optional but Recommended):

If you plan to host your code on GitHub. You can sign up for free at https://github.com/join.

Let's dive into how I got everything configured.
1. Picking My Tools: Editor, Python, & Git

  • Code Editor

Choose one and install it.

PyCharm Community Edition(Recommended for Python):
Download from:

https://www.jetbrains.com/pycharm/download/,
Enter fullscreen mode Exit fullscreen mode

VS Code (Versatile):
Download from:

https://code.visualstudio.com/download.
Enter fullscreen mode Exit fullscreen mode

I chose VS Code and Downloaded. Sometimes I need something lighter or for other languages, and that's where VS Code shines. It's incredibly versatile and customizable.

  • Install Git for version control.

I Downloaded Git:

https://git-scm.com/downloads
Enter fullscreen mode Exit fullscreen mode

Follow the installer instructions.
Verify Installation: Open the terminal and run:
git --version

  • Installing Python 3.10+: My Language of Choice

Download Python: I downloaded the latest Python from

https://www.python.org/downloads/ 
Enter fullscreen mode Exit fullscreen mode

During installation, I ensure I check the "Add Python to PATH" option.

Image description

Verify Installation in the terminal with python --version and git --version.

4. Setting Up WSL: My Linux Playground on Windows

  • How I installed it:

I opened PowerShell as Administrator.
Execute the installation command: wsl --install
My computer needed a restart after that, so I let it do its thing.
After restart, I follow the prompts to set up the Linux username and password.
I then set up the Linux environment.

5.Installing Docker Desktop:

  • How I installed it:

I downloaded Docker Desktop from

docker.com.
Enter fullscreen mode Exit fullscreen mode

It uses WSL2 for great performance.

Image description.

After installation, I opened my terminal (or my WSL terminal) and ran: docker --version to check it was ready.

6. Configuring Git with GitHub SSH:

  • Checking for existing keys:

I first checked if I already had SSH keys lying around. I ran:
ls -al ~/.ssh.

If I saw files like id_ed25519.pub or id_rsa.pub, I would have skipped to next step. But, I generated a new one for a fresh setup.

  • Generating a new SSH key (if I didn't have one):

This command creates a new, strong SSH key. I made sure to replace "[email protected]" with the email linked to my GitHub account.
ie... ssh-keygen -t ed25519 -C "[email protected]"

When it asked for a file location, I just pressed Enter to accept the default (~/.ssh/id_ed25519).

  • Copying my public SSH key:

I needed to get my public key so I could paste it into GitHub. I displayed it with:
cat ~/.ssh/id_ed25519.pub

Then, I carefully copied the entire output (starting from ssh-ed25519 or ssh-rsa all the way to my email address)

  • Adding the SSH key to my GitHub account:

I went to [https://github.com/settings/keys] and logged into my GitHub account.

I clicked on the "New SSH key" (or "Add SSH key") button.
I gave it a meaningful Title.
Then, I pasted my copied public key into the "Key" field.

Finally, I clicked "Add SSH key". GitHub might ask for password one last time to confirm.

Image description

Conclusion

That's the rundown of how I set up my Python development environment! It might seem like a few steps, but each one contributes to a smoother and more efficient coding experience. With your chosen editor, Python ready to go, Git for version control, WSL and Docker for consistent environments, and secure SSH access to GitHub, you're well-equipped to tackle any Python project. ~~Happy ~~coding!

Top comments (0)