Python starting with Windows 7

Insco of the main body

First of all, even if there is nothing, I will fetch the main body. Currently (December 2014), python has both 2.x and 3.x series. This time, I will use 2.x series, which has a lot of documentation, especially version 2.7, which is the mainstream.

Well, it was a PC a long time ago, so download the installer for 32bit from python head family.

Python_Releases_for_Windows___Python_org.png

Launch the downloaded installer and press OK at will to complete the installation of python itself.

path setting

I've installed python, but I need to make sure the system can find it. Add the location of the python installed this time (C: \ python27) to the location where the system searches for the execution command (environment variable called Path).

First, open the screen where you can edit the environment variables.

Control> System-> Advanced System Settings-> Environment Variables

Looking at the system environment variables in the screen that appears, I think there is a variable Path. Select it and press the edit button.

win-path-set.png

Add the following to the variable value of the screen that appears (backslash is a yen mark)

C:\Python27;C:\Python27\Scripts;(Existing)

After writing, press OK to close some open windows.

Confirmation of main body insco

Menu-> Accessories> Command Prompt

From, open the terminal,

python --version

Hit. If the version information such as "Python 2.7.9" is returned, it is successful.

win-py-ver-check.png

<!-With ez_setup

python ez_setup.py

-->

pip insco

To develop with python, you have to insuko various packages (libraries (collections of utilities created by others)) and use them.

If a certain package is created on the premise of a certain package, the original package must also be installed ... What? If you go with this version, it will take many days just to insuko.

The package management tool solves this problem all at once. Among them, this time we will put pip (Python Package Installer) recommended by python. The procedure is simple.

easy_install pip

It will be inscored just by (I put a path to Scripts with the above Path setting, but easy_install is included there).

Insco what you need

To insuko using pip, you can insuko by doing the following. As a test, let's insuko ipython.

pip search ipython

When you see the package you want, let's go next.

pip install ipython

only this.

BeautifulSoup

Insuko Beautiful Soup before testing. This is a library that structures HTML code so that it is easy to handle programmatically.

pip install BeautifulSoup

Let's write the code

Any text editor is fine, but since it's a big deal, I'll introduce the oython editor for beginners.

Go to the PyScripter page and download the file PyScripter-v *. *. *-Setup.exe in Featured. ,I will do it. (If you are using a 64-bit machine, please select the file that says x64.)

pyscripter_-An_open-source_Python_Integrated_Development_Environment__IDE_-_Google_Project_Hosting.png

Follow the installer's instructions faithfully and let's OK like a tuna. It is convenient to start it if you generate an icon on the desktop.

Start pyscripter and write the following code.

import urllib2 # get request from url via the internet.
from BeautifulSoup import BeautifulSoup # html parser

def getTitle(url):
	# get the server response
    res = urllib2.urlopen(url)
    # load html code
    html = res.read()
	# analyse html code
    bs = BeautifulSoup(html)
	# extract the text of title
    return bs.title.text

def main():
    url = "http://docs.python.jp/2.7/tutorial/index.html"
    title = getTitle(url)
    print title

if __name__ == '__main__':
    main()

Save it to a suitable location with Ctrl-s (I save it under C: / Users / myname / develop /) and execute it with Ctrl-F9.

It's nothing but code that shows the title of the url in the source, but it's the basis of HTML parsing.

···to be continued.

Recommended Posts

Python starting with Windows 7
GRPC starting with Python
Reinforcement learning starting with Python
Python starting with Hello world!
Time synchronization (Windows) with Python
Face detection with YOLO Face (Windows10, Python3.6)
Build mlpy with python3.3 (64bit) (windows 64bit)
Use Windows 10 speech synthesis with Python
Data analysis starting with python (data visualization 1)
Getting started with Python 3.8 on Windows
[Python] Creating multiple windows with Tkinter
Data analysis starting with python (data visualization 2)
[Python Windows] pip install with Python version
FizzBuzz with Python3
Scraping with Python
Statistics with python
Python on Windows
Scraping with Python
Python with Go
python windows environment
Integrate with Python
Python installation (Windows)
AES256 with python
Tested with Python
python starts with ()
with syntax (Python)
Bingo with python
Zundokokiyoshi with python
Excel with Python
Microcomputer with Python
Cast with python
System trading starting with Python3: long-term investment
Run servo with Python on ESP32 (Windows)
"Python AI programming" starting from 0 for windows
"System trade starting with Python3" reading memo
Building a Python 3.6 environment with Windows + PowerShell
Business efficiency starting from scratch with Python
Develop Windows apps with Python 3 + Tkinter (Preparation)
Data analysis starting with python (data preprocessing-machine learning)
"First Elasticsearch" starting with a python client
Serial communication with Python
Zip, unzip with python
Primality test with Python
Python with eclipse + PyDev.
Socket communication with Python
Data analysis with python 2
Scraping with Python (preparation)
Try scraping with Python.
Sequential search with Python
Machine learning starting with Python Personal memorandum Part2
"Object-oriented" learning with python
Run Python with VBA
Solve AtCoder 167 with python
Serial communication with python
[Python] Use JSON with Python
Learn Python with ChemTHEATER
Run prepDE.py with python3
python windows environment construction
Collecting tweets with Python
3. 3. AI programming with Python
Kernel Method with Python