Initial setup guide for a Python Developer
Tags: machinelearning, python, beginners, programming
Published: 2023-07-13 16:41:03

Everytime we get a new machine or we begin with our Python development journey, we developers spend a lot of time in setting up and customizing the software features to suit our needs and convenience. Over the time we keep on changing and adding some configurations that contribute to our productivity and efficiency hugely. Ideally we should document all the set up related steps and changes so that we can easily reproduce our customized environment. That would help us focus more on the development work without being much worried about the environmental setup anymore. However, unless we document our settings and customizations, it becomes cumbersome and effort intensive to recreate that tailored setup.

I am writing this article to document my windows machine setup and hope others find it useful.

**Disclaimer**
The considered softwares and configurations are for Windows OS and as per author's choice only. No two developers are same and every one has their own setup and configurations of choice. Please feel free to skip any points that are not relevant to you. I will highly appreciate if you suggest any of your best practices in the comment section, I will be happy to incorporate the same in the revision.

From time to time, I will keep updating this article to accommodate new settings.

#Python Installation#
* Install Python from the official site https://www.python.org/downloads/
* Copy the Python installation path as well as path of Scripts folder inside that and add those to environment variable 'path'
* Go to terminal and verify the installed Python version with command ```python --version```


#Virtual Environments#
Virtualenv is one of the most popular libraries for creating and managing virtual environments. Virtualenvswrapper-win is an extension to it for Windows that provides more convenient commands to work with. It might create some conflict if pyenv-win is being used. Note, Virtualenvswrapper-win works with Command Prompt but not with Powershell.
* Use command ```pip install virtualenvwrapper-win``` to install the library
* Follow list of commands listed on https://pypi.org/project/virtualenvwrapper-win/ to work with environments

#Jupyter in Virtual Envs#
* On command prompt execute ```pip install jupyter```
* Create and activate the required virtual environment.
To create: ```mkvirtualenv <name of virtual env>```
To activate: ```workon <name of virtual env>```
* Run following command that installs all the dependencies for Jupyter
```pip install ipykernel```
* Run following command. Usually environment name is given as kernel name for simplicity.
```Python –m ipykernel install –user –name=<any name for kernel>```
* Run ```jupyter notebook``` command to spin up notebook server and set the correct environment from the kernel list in the notebook.
* [FOR DELETION] To remove a virtual environment from the notebook kernel list run the following commands to view and delete.
```jupyter kernelspec list```
```jupyter kernelspec uninstall <my_kernel_name>```

#IDE Installation#
I personally prefer VS Code editor over anything else. Well, if I have a second choice then that will be PyCharm. In this article I will cover VS Code part only.

* Download and install VS Code from official site https://code.visualstudio.com/download
* Go to Extensions in VS Code and install the following popular ones:
 * pylance (language server for Python)
 * Python (For linting, debugging, formatting etc)
 * Code Runner (To run code of a number of languages)
 * Error Lens (To highlight errors and warnings)
 * indent-rainbow (indentation readability)
 * Python Docstring (To generate docstrings)
 * Jupyter (For jupyter notebook support)
 * Jupyter Keymap
 * Jupyter Notebook Renderers
 * Markdown All in One ( To write and preview markdown files)
 * Spell Right (Multilingual spellchecker)
 * YAML (YAML language support)
 * YAML Sort (To use in conjunction with YAML)
 * Quick and Simple Text Selection
 * Todo Tree
 * Bookmarks
 * File Utils
 * GitLens - Git supercharged (Visualize code authorship)
 * Docker
 * Kubernetes
 * Remote - Containers (Access any folder from a Docker container)
 * Project Manager
* Search for "Default Language" in Settings and add "python" there
* Go to "Python: Language Server" in Settings and change it to Pylance
* Open "Keyboard Shortcuts" in Settings and search for "Run Code". Change Keybindings to "Ctrl + Enter" or any other combination of your choice for convenience.

Thank you for reading and I hope you found this useful.