iXora Custom Software Development Blog

Read | Practice | Advance

Python Development In Visual Studio 2017

Posted by on in Blog
  • Font size: Larger Smaller
  • Hits: 1849

Python at a glance

  • Python is an interpreted, high-level, general-purpose programming language. Created by Guido van Rossum and first released in 1991
  • Python is a server side programming language.
  • Python is targeted for almost all platforms
  • Python is a modular language like nodejs
  • Python is a indent sensitive language

 Development environment setup

  1. Go to https://www.python.org/downloads/ and download latest (or earlier) version of Python for Windows OS
  2. Install Python using run as administrator in your local machine with features pip, tcl/tk (for winform app), test suite, py launcher. For more to install python environment you can visit the link.

Checking Environment is OK or not

  • Open command prompt
  • To know python version execute python --version
  • To know pip (python packages installer) version execute pip --version or execute pip list
  • If you can see the result as screenshot below then it's Okay.
  • Otherwise there may be some problem during installation and Check system environment variable PATH value discussed in later section

System Environment Variables for Python

If python is correctly setup then system environment variable PATH will contain two directory path such as 

  1. python.exe container directory. In my case it is C:\Program Files (x86)\Python37-32\
  2. pip.exe container directory. In my case it is C:\Program Files (x86)\Python37-32\Scripts\

If somehow these aren’t set automatically then you have to set those manually and check again using python --version and pip --version command

Python in Visual Studio 2017

.NET developer can easily work on python in visual studio 2017 or later and as well as earlier version with some workarounds.
If you can setup python environment correctly, You can see the python environments in visual studio from menu View→Other Windows→Python Environments and Python Interactive Window as screenshot below

Create python project in VS 2017

Open Visual Studio and Go to File menu then New -> Project then as screenshot below

Installing package

As I said above, Python is a modular language like nodejs. Here you can also install pip packages whatever you need. To install any package you have to right click on python environment node in your puthon project and select Install Python Package then search for your package ( in my case mssql) and click on your desired package link as shown below.


Python code snippet

You may not need to remember all python code syntax. Visual studio will help you to insert code snippet into your place using Ctrl+K Ctrl+X.
Or you type any python keywords such as for, if etc and press TAB, you will get full statement structure as shown below

Simple python program

  • This program imports environ dictionary defined in os package.
  • Gets all keys and prints the values and finally prints the count.
  • None is same as null in other language
from os import environ
print("My Environment Information")
keys = environ.keys()
count = 0
for key in keys:
    if environ[key] != None:
            print(key + " = "+ environ[key])
            count += 1
print("There are ", count, " information")

Debugging & Watching is same as .NET program

You can set break point and debug as .Net program as well as can view any variable value in watch windows as below


Related Links



I think this session may help for Python beginners as well as .NET guys.

Rate this blog entry:


  • No comments made yet. Be the first to submit a comment

Leave your comment

Guest Wednesday, 20 January 2021