Setting up Python in Windows 10

Installing Python under Windows 10 is easy as long as you set up your system environment correctly.

Ready? Here’s your quick guide:

1. Visit the official  Python download page  and grab the Windows installer for the latest version of Python 3. A couple of notes:

  • Python is available in two versions – Python 2 and Python 3. For beginners, that may be confusing. In short, Python 3 is the current and future state of the language; Python 2 is a legacy version that has a large base of users. Python 2 wants to  reach its end of life in January 2020  and will only fix bug till then.
  • By default, the installer provides the 32-bit version. There’s a 64-bit version available. I’m getting stuck with 32-bit for compatibility issues with some older packages.

2. Right-click on the installer and select „Run as Administrator.“ You’ll have two options – choose „Customize Installation.“

3. On the next screen, check all boxes under „Optional Features.“ Click next.

4. Under „Advanced Options,“ set the location where you want to install Python. For ease, I use:

C: \ Python36-32

How to install 32-bit Python 3.6.

Click „Install.“ When the installation finishes, close the installer.

5. Next, set the system’s PATH variable to include directories that include Python components and packages we’ll add later. To do this:

  • Open the Control Panel (easy way: click on the task bar, type „Control Panel,“ then click the icon).
  • In the Control Panel, search for Environment; click Edit the System Environment Variables. Then click the Environment Variables button.
  • In the User Variables section, you want to edit PATH variable or create one. If you’re editing an existing PATH, the values ​​are presented on separate lines in the edit dialog, like this:
C:\Python36-32 
C:\Python36-32\Lib\site-packages\
C:\Python36-32\Scripts\
  • If no PATH variable exists on your system, create one by clicking New. Make PATH the variable name and add the above directories to the variable values section as shown, separated by a semicolon:
C:\Python36-32;C:\Python36-32\Lib\site-packages;C:\Python36-32\Scripts
  • Click OK to close all the Control Panel dialogs.

6. Now, you can open a command prompt (Start Menu > Windows System > Command Prompt) and type:

python

That will load the Python interpreter:

Python 3.6.5 (v3.6.5:f59c0932b4, Mar 28 2018, 16:07:46) [MSC v.1900 32 bit (Intel)] on win 32
Type "help", "copyright", "credits" or license for more information.
>>>

Because of the settings you included in your PATH variable, you can now run this interpreter — and, more important, a script — from any directory on your system.

Type exit() and hit Return to exit the interpreter and get back to a C: prompt.

Optional: Set up useful Python packages

Python 3 comes with the package installer  pip  already in place, Which makes it super easy to add useful packages to your Python installation. The syntax is this (replace  some_package  with a package_name you want to install):

pip install some_package

1. Let’s add a couple of must-have utilities for web scraping:  Requests  and  BeautifulSoup . You can use the install all with one command:

pip install beautifulsoup4 requests

2.  csvkit , which is  covered here , is a great tool for dealing with comma-delimited text files. Add it:

pip install csvkit

You’re now using Python under Windows 10.

Schreibe einen Kommentar