banner



How To Setup Python Environment On Windows

How to Gear up Up a Python Development Environment on Windows

This tutorial is for Windows users who want to get their computer set up for developing with Python.

  • What is Python?
  • What Do I Need?
  • Installing Python
  • Installing Cygwin
  • Installing Sublime Text
  • Verify that it all works

What is Python?

Python is a programming linguistic communication that is easy to larn, yet powerful and flexible. Many professional software engineers use Python every day to do their task, for both large projects and small ones. Python is free, open source, and it runs on Windows, Mac, and Linux, every bit well every bit many other operating systems. It'southward a not bad linguistic communication if you desire to start learning how to write figurer programs.

What Do I Need?

To finer use Python on Windows, you need a few pieces of software:

  • Python
  • Cygwin
  • Sublime Text or some other text editor

Let's handle them one at a time.

Installing Python

Go to python.org and download the version of Python that you want. In these examples, I'm downloading Python three.2.iii.

python 3.2.3 homepage python 3.2.3 download

Run the installer, and let it install to the default location: in this case, C:\Python32\.

python 3.2.3 installer intro python 3.2.3 installer location

That was easy!

Installing Cygwin

This is a bit more complicated. Get-go, go to the Cygwin homepage, download setup.exe, and run information technology.

cygwin homepage cygwin installer intro

Cygwin is a programme that can download and install other programs from the internet for you. You'll need to give information technology some information about your internet connection, although most of the time you can just accept the defaults and keep going.

cygwin installer 1 cygwin installer 2 cygwin installer 3

Side by side, Cygwin will testify you a long list of download sites. Each 1 is exactly the same: you can pick one at random. Y'all do non need to pick the aforementioned download site shown in the screenshot. After y'all've picked ane and clicked the "side by side" button, y'all'll see an upgrade warning, but that only applies to people upgrading from an older version of Cygwin. Since this is a new installation, we can ignore it.

cygwin mirrors cygwin installer warning

Now, nosotros go to select what software we want to install from the download site. Nosotros want to install three software packages: openssh, git, and curl. For each i, use the search box to find the packet, and and so click on the discussion "Skip" so that it changes to a version number. Install the latest available version for each of these packages.

cygwin ssh cygwin git cygwin curl

Next, Cygwin will tell you lot that yous need to install certain other packages as dependencies. Basically, this means that if you want to apply a sure package named A, and A relies on another packet named B in club to run correctly, then Cygwin will detect this and enquire to install package B also. You can just hitting "Next". At that point, Cygwin will get-go downloading and installing all the packages that you lot've requested, equally well every bit all their dependencies. Depending on the speed of your cyberspace connection, this may take a petty while. When the heart of the three progress bars (the one marked "Total") is full, Cygwin is finished.

cygwin dependencies cygwin progress

If you ask Cygwin to install an icon on your desktop, it will do then, creating a shortcut named "Cygwin Terminal". You lot'll use this icon to run your Python code, too every bit to access the openssh, git, and curl packages that yous installed. Double-click the icon to run Cygwin Terminal, and you'll see a window like this pop up:

terminal first run

The exact text in your terminal window will be a footling different, since it depends on the name of your figurer, and the name of your user business relationship. Now we tin showtime using the terminal: if you don't know how, I suggest y'all read this tutorial on how to use the command line. Get-go, permit'south use the which command to find out where those packages are that nosotros installed:

terminal which

And so information technology looks like the terminal can find ssh and git, simply not python. That's understandable, since we didn't use Cygwin to install Python. To tell Cygwin how to find Python, run the following control:

                        echo            "PATH=\$PATH:/cygdrive/c/Python32"            >> .bash_profile          

Note that you're using the aforementioned directory that you installed Python into: if you're installing a different version of Python, then supersede Python32 with the version of Python you take installed. You should only need to do this once: subsequently you lot've run that control, the terminal will always be able to notice Python again.

terminal path

You lot're finally done installing and setting upward Cygwin!

Installing Sublime Text

Lastly, you'll demand a text editor. In that location are many good options, but I suggest Sublime Text: it's very powerful and useful, and it has an unlimited free trial. Please annotation that Microsoft Word is a give-and-take processor, not a text editor: y'all cannot use Microsoft Word for writing reckoner programs.

Installing Sublime Text is like shooting fish in a barrel: just get to the Sublime Text homepage, download the installer, and install it. Sublime Text is not free software, but y'all tin can try information technology for as long equally you like before you lot purchase information technology. If yous terminate up writing many programs using Sublime Text, I encourage you to buy a license.

sublime text homepage

Verify that information technology all works

Now that y'all're all set, let's verify that everything is working properly! The first program that any developer writes is called "Hello, World!", and all information technology does is write that text out to the last. So, let's write "Hello, World!" in Python! If your computer is prepare up properly, this should work properly:

            $ python -c            'print("Hello, World!")'            Hello, Earth!          

If that works, lets move on to writing a program into a file. Open upwardly Sublime Text, and blazon in the following:

                        #!/usr/bin/env python            print            (            "Hello, Earth!"            )          

Save the file in your home directory (inside of C:\cygwin\home) every bit hello.py. So open up up the Terminal, cd to that directory, and run:

            $ chmod a+x hi.py $ ./hello.py Hello, Globe!          

And you should run across the same Hi, World! output that you saw before. Congratulations, yous're ready to commencement learning Python!

Source: https://www.davidbaumgold.com/tutorials/set-up-python-windows/

Posted by: mcginnismanday.blogspot.com

0 Response to "How To Setup Python Environment On Windows"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel