Python Overview _ Installation _ FAQ

Source: Internet
Author: User
Tags vc9 sublime text pycharm download

1. Python Installation

There are currently 2 large versions of Python, 2 and 3, and because of the differences between the 2 and 3 syntaxes, many of the existing libraries are based on python2 development, and this series of articles is dominated by Python2.

1.1 Important concepts

1. Dynamic language

Run-time binding, which determines the type when the variable is executed

Variables are equivalent to references in C + +

Can be modified at run time

2. Everything is the object

Everything is an object, including numbers, strings, functions, lists, and even classes

1.2 Installation under Windows

1, visit https://www.python.org/website Download python installation version, I use 2.7 version, can download a file named Python-2.7.8.msi, where 2.7.8 refers to the latest version number

2. Double-click the downloaded file in Windows and install it according to the installation wizard

3. Configure environment variables after installation, add D:\Program files (x86) \python27 and D:\Program files (x86) \python27\scripts in Path (after installing Setup-tools)

4, assuming the installation of all normal, you can find the Python-idle (Python GUI) in the Start menu, open to see the following interface, enter the corresponding content test installation can be

1.3 Linux under Upgrade

CentOS 6.3 comes with a python version of 2.6, you can use "python–v" to view the Python version, first need to upgrade to the 2.7 version. Because older versions of Python are deeply dependent, you cannot uninstall the original Python, only the new installation. Use root to do the following:

1, download Pyhon, select download gzipped source tar Ball (2.7.6) (sig), URL https://www.python.org/download/releases/2.7.6

2, decompression installation, the command is as follows

TAR–XVF python-2.7.6.tgz

CD Python-2.7.6

./configure--prefix=/usr/local/python2.7

Make

Make install

3. Create a link to change the system default Python to python2.7

Ln-fs/usr/local/python2.7/bin/python2.7/usr/bin/python

4. View Python version

Python–v

5. Modify the Yum configuration (otherwise Yum will not work)

Vi/usr/bin/yum

Modify the #!/usr/bin/python of the first line to the original Python version address #!/usr/bin/python2.6 of the system, CentOS6.3 system Python has been successfully upgraded to version 2.7.6.

2. Development environment Pycharm

Python has a lot of development environment, with its own idle, wingide, sublime text, etc., this article describes the Pycharm,pycharm can be cross-platform, both MacOS and Windows can be used.

1, first to pycharm download version to install, I use the free version, the recommended purchase of the official version, download completed according to the Installation Wizard installation

2. First Use click Create New Project.

3. Enter the project name, path, and select the Python interpreter. If the Python interpreter does not appear, click the button on the back of the interpreter, and then select the EXE of the locally installed Python.

4, click OK, will create a new project, you can start your programming learning journey

5. Right-click on the newly built Helloword project and choose New---Python File

6, Pycharm The default editing interface is very strange, will automatically generate a line __author__ = "Author" of the head, enter Code:print "Hello word!", click on the menu run

3. Installation of other Python libraries

Note: 1. All additional third-party libraries installed, if not specified after the installation of the Library directory, will be saved by default to%python_home%\lib\site-packages, 2.python case sensitive, the module name is also. 3.Crypto can provide common encryption and decryption algorithms such as RSA, RC4, DSA, DES

3.1 Installing Setuptools

1, the official website recommends using ez.setup.py to install, first download ez.setup.py,https://bitbucket.org/pypa/setuptools/raw/bootstrap/ez_setup.py

2. After the download is complete, cmd enters the python installation directory, performs the operation Python.exe ez_setup.py

After downloading the latest version, the system will automatically install Setuptools, after installation, there will be a Python installation directory under the scripts of a easy_install.exe executable file.

3.2 Installing PIP

1. Install under Windows

Under the command line (CMD) into the Python installation directory under the script path to execute Easy_install.exe Pip, after the installation is complete, you can see pip.exe under scripts.

2. Install under Linux

Pip is a tool for installing and managing Python packages. The installation method is as follows (URL http://www.pip-installer.org/en/latest/installing.html):

(1) Download Pip, address https://raw.github.com/pypa/pip/master/contrib/get-pip.py

(2) Execute the installation command

Python get-pip.py

(3) Create connection (otherwise error message "Command not Present")

Ln-s/usr/local/python2.7/bin/pip/usr/bin/pip

Note: If the connection prompt error "ln:creating symbolic link '/usr/bin/pip ': File exists" You need to manually delete the Pip file, and then re-connect the soft connection, you can use LL for connection check after the operation is completed

3.3 Installing the SSH module under Windows (PARAMIKO+PYCRYPTO+ECDSA)

1, installation Pycrypto

Installing this is cumbersome and requires local compilation, and there is a lot of configuration for VS or GCC, and it's not necessarily possible to compile successfully. It is recommended to download the compiled version directly: Http://www.voidspace.org.uk/python/modules.shtml#pycrypto directly download and install both.

2, Installation ECDSA

When you execute the command, you are not prompted to find the ECDSA module. Download: https://pypi.python.org/pypi/ecdsa/0.9, unzip to a directory, there is a setup.py in the directory. Under Windows directly after the extracted directory execution: Python setup.py install

3, Installation Paramiko

With the installation ECDSA type, download: https://github.com/paramiko/paramiko#, installation steps with ECDSA, unzip to a directory, there is a setup.py in the directory. Directly after the extracted directory execution: Python setup.py install

3.4 Installing the Fabric

1. Install under Windows

Execute command at command line (CMD) pip install fabric, prompt OK, may encounter problems unable to find Vcvarsall.bat, after resolving the problem according to the following workaround, remove the files that have been installed to re-execute the command, "python\ Folder fabric and Fabric-1.10.0-py2.7.egg-info under the Lib\site-packages folder.

2. Install under Linux

(1) Execute the installation command

Pip Install Fabric

(2) Create connection (otherwise error message "Command not Present")

Ln-s/usr/local/python2.7/bin/fab/usr/bin/fab

4. FAQ 4.1 Tip Python is not an internal or external command, or a program or batch file that can be run.

Because there is no environment variable configured for Python, the configuration can be

4.2 Extension Issues Unable to find Vcvarsall.bat

Using PIP to install a library times unable to find Vcvarsall.bat, you can retrieve the msvc9compiler.py file in the Python installation path, modify the Msvccompiler function vc_env = Query_ Vcvarsall (version, Plat_spec) is: vc_env = Query_vcvarsall (8.0, plat_spec), or add Find_vcvarsall before function version= (version) 8.0

Description: The problem is to find the directory of VS in the registry, and then go to the VS directory to find Vcvarsall.bat, but Python is the default vc9.0, that is, vs2008, so it can not find the key value in the registry return none,

Productdir = Reg.get_value (r "%S/SETUP/VC"% vsbase, "Productdir")

The Vsbase value is: software/microsoft/visualstudio/9.0

In msvc9compiler.py, the Def find_vcvarsall (version) is used to find the Vcvarsall.bat version, which is the release number, which is actually 9.0.

Vc_env = Query_vcvarsall (version, Plat_spec), Version = Get_build_version () because Python32 was built by vc9.0, version is 9.0.

4.3 Fab execution error pkg_resources. distributionnotfound:ecdsa>=0.11

Need to install SSH module

4.4 About Python error: syntaxerror:non-ascii character ' \xe5 '

The problem occurs because Python defaults to ASCII as encoding, and if you include other characters such as Chinese in your Python source, you will get an error.

Workaround: Add the following statement in the first line of the source code, #-*-Coding:utf-8-*-or #coding =utf-8 (Note: This statement must be added to the first line of the source)

4.5 Compile error indentationerror:expected an indented block

The Python language is a language that is very sensitive to indentation, and the most common case is that the mix of tabs and spaces results in errors, or indentation, which cannot be separated by the naked eye.

This error will occur at compile time indentationerror:expected an indented block indicates that indentation is required here, as long as you press space or tab (but not mix) to indent the line in the wrong line.

5. Common Command Introduction

Multiline Comment: Select the line you want to comment on, ctrl+/

Uncomment multiple lines: Select the line you want to uncomment, ctrl+/

To view the method, hold down CTRL and click directly on the function name to see the type of the definition parameter

6. References

http://blog.csdn.net/chenggong2dm/article/details/9365437

http://blog.csdn.net/chenggong2dm/article/details/9366805

Http://blog.useasp.net/archive/2014/01/16/install-python-setuptools-pip-and-virtualenv-in-windows.aspx

http://blog.csdn.net/ren911/article/details/6448696

http://chenpeng.info/html/2551

Python Overview _ Installation _ FAQ

Related Article

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.