Python advanced programming (1)-preparation, python Advanced Programming

Source: Internet
Author: User

Python advanced programming (1)-preparation, python Advanced Programming

1.1 install 18

The version here is 2.7.9; https://www.python.org/downloads/release/python-279/

InstallMinGW: Compilers developed for WIndows platforms have gcc functions instead of VC ++;

Http://www.mingw.org/

Http://sourceforge.net/projects/mingw/files/Installer/

Download mingw-get-setup.exe;

Install it on D: \ Pythons \ MinGW;

Run mingw-get.exe in the bindirectory, and select all the packages under MinGW Compiler Suite (the function is not fully selected );

Menu bar Installation-> Apply

Then download and install the SDK;

Download takes a long time. From time to time, it may be interrupted because it cannot be connected to sourceforge. If you fail to download and install it again, check whether D: \ Pythons \ MinGW \ bin is installed, there are many tools;

D: \ Pythons \ MinGW \ bin is added to the environment variable. for verification, the command line executes gcc-v. It is automatically called when the Python compiler needs it;

InstallMSYS

MSYS can provide a Bourne Shell command line execution environment on the Windows platform; Bourne Shell is a standard Unix Shell, that is, bash;

This environment can implement common commands in Linux or Mac OS X, such as cp and rm;

You don't need to download it here. MinGW has it in it. You can install it;

After MinGW and MSYS are installed, the main functions of Linux are available in windows;

1.2 command line 25

9: 29

Enter python in the command line to enter the command line, for example, small computing, such as 1 + 3;

Press enter,PythonParse the program immediately and return the resultThis feature is inherited from the ABC language;

ABC is a teaching language specially designed for non-professional programmers;

Exit the command line: windows, Ctrl + Z (and press Enter); Linux/Mac, Ctrl + D;

1.2.1 custom interactive command line 26

9: 36

Through the Startup File configuration, the environment variable PYTHONSTARTUP will be searched during startup to execute the code in the file;

By default, There Is A. pythonstartup in the main directory. function: Tab auto-completion, command history;

This is implemented based on the readline module (readline library is required );

Check whether the readline module is installed in python;

Command Line input: help (), and then enter modules;

You can also search for the prompt. Enter modules readline;

There is a mini version of readline;

. Pythonstartup, which can be downloaded at https://pypi.python.org/pypi/pbp.scripts;

"G: \ pbp. scripts-0.2.5 \ pbp \ scripts \ pythonstartup. py"

Change pythonstartup. py to. pythonstartup;

But cannot be renamed:

It's okay. Keep the original name and try to configure the environment variable;

Then go to the command line;

The system prompts that no readline module exists;

Download installation, http://newcenturycomputers.net/projects/readline.html

Readline-1.7.win32-py2.6.exe

Install readline;

Check whether python is 32-bit or 64-bit. You can see it when you enter the command line;

The previous readline problem was that version 27 was installed and the registry was not version 26;

Add; regedit,

HKEY_LOCAL_MACHINE \ SOFTWARE \ Wow6432Node \ Python \ PythonCore \ 2.6 \ InstallPath

Re-install:

Installation complete;

Traceback (most recent call last ):

File "D: \ Python27 \ pythonstartup. py", line 2, in <module>

Import readline

File "D: \ Python27 \ lib \ site-packages \ readline. py", line 32, in <module>

Import sys, OS, msvcrt, _ rlsetup

ImportError: DLL load failed: the specified module cannot be found.

I checked it online. In Windows Python 2.7, readline is invalid in windows.

Install pyreadline;

Execute pip install pyreadline;

It seems that the installation module can use pip install;

Verification;

Delete the environment variable. This pyreadline does not need a configuration file;

Automatic tab completion does not take effect;

OS. environ ['home'] keyerror: 'home', because the windows environment does not have the HOME environment variable, which corresponds to HOMEPATH;

Run: import OS

OS. environ. keys () can be viewed;

Change it to HOMEPATH;

Verification:

Yes !!!!!!!!!

Nima

Installing modules is so boring!

Summary: Use the tab to automatically complete the configuration. install pip install pyreadline and pythonstartup. py in version 27:

Http://git.oschina.net/yejq/PythonRel/blob/master/conf/pythonstartup-windows.py

1.2.2 iPython: enhanced command line 27

Extended command line:

· Dynamic Object reflection;

· Call the system shell function in the command line;

· Direct support for program optimization;

· Debugging tools;

Install: pip install ipython

1.3 install setuptools 28

Setuptools: package management system. It releases Python applications, which is equivalent to apt In Debian;

PyPI (Python Package Index): centralized repository;

Currently, it is not a standard library and must be installed;

1.3.1 install with EasyInstall

EasyInstall seems to have been installed;

"D: \ Python27 \ Scripts \ easy_install.exe"

Check whether setuptools is installed;

Seems to have been installed;

1.3.3 integrate MinGW into distutils 31

To compile a program, you can create distutils. cfg in the Directory D: \ Python27 \ Lib;

Content:

[Build]

Compiler = mingw32

In this way, MinGW can be linked to Python. Every time Python needs to compile a package containing C program code, MinGW will be automatically called;

1.4 work environment 31

I use pycharm-professional-4.0.4 here;

1.4.1 install and configure vim 33

Vim is recommended in the book;

Start the MinGW Shell and check whether the MinGW Shell is installed;

Input vim-version;

Not installed;

You can find it in MinGW Installation Manager, MSYS, and MinGW Developer Toolkit;

Install it; the old connection fails, and it has been reinstalled many times;

You can also install gvim;

I am too lazy to configure it here. I have reached out to the party and used the green version of a great God on the Internet;

Http://www.oschina.net/code/snippet_574132_13357

1.4.2 IDE

Install eclipse with PyDev plug-in;

Marketplace;

Install it;

Unable to connect;

Try Install Updates;

Http://pydev.org/updates

Go to this URL: https://dl.bintray.com/fabioz/pydev/all/

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.