Python overview _ software installation _ FAQs and python Overview

Source: Internet
Author: User
Tags vc9 pycharm download

Python overview _ software installation _ FAQs and python Overview

 

1. Python Installation

Currently, python has two major versions, 2 and 3. Due to the differences in the syntax between 2 and 3, many existing libraries are developed based on python2. This series of articles focuses on python2.

1.1 important concepts

1. Dynamic Language

BIND at run time. The variable determines the type only when it is executed.

Variables are equivalent to references in C ++.

Modify when running

2. Everything is an object

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

1.2 Windows Installation

1. Access ingress

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

3. Configure the environment variables after installation. Add D: \ Program Files (x86) \ Python27 and D: \ Program Files (x86) to the path) \ Python27 \ Scripts (after setup-tools is installed)

4. If the installation is normal, you can find Python-IDLE (Python GUI) in the Start Menu, open the interface, and enter the corresponding content to test the installation.

1.3 upgrade in Linux

CentOS 6.3 comes with Python version 2.6. You can use "python-V" to view the python version. You must first upgrade it to version 2.7. Because the old version of Python has been deeply dependent, You Cannot uninstall the original Python and can only install it completely. Use root to perform the following operations:

1. Download Pyhon, Select Download Gzipped source tar ball (2.7.6) (sig), Web site https://www.python.org/download/releases/2.7.6

2. Unzip the package and run the following command:

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 python to python2.7 by default.

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

4. view the Python version

Python-V

5. Modify the yum configuration (otherwise, yum cannot run properly)

Vi/usr/bin/yum

Set the #! Of the first line #! /Usr/bin/python to the original python version address #! /Usr/bin/python2.6. Now, Python in CentOS6.3 has been successfully upgraded to version 2.7.6.

2. Development Environment Pycharm

Python has many development environments, including built-in IDLE, wingIDE, and sublime text. This article describes Pycharm. pycharm can be used across platforms and can be used in both macos and windows.

1. First, go to the Pycharm download version for installation. I am using the free version. We recommend that you purchase the official version. After downloading it, follow the Installation Wizard to install it.

2. Click Create New Project for the first time.

 

3. Enter the project name and path, and select the python interpreter. If the python Interpreter does not appear, click the button after Interpreter and select the locally installed python exe.

 

4. Click OK to create a new project and start your programming learning journey.

5. Right-click the created helloWord project and choose New --> Python File

6. The default editing interface of PyCharm is very strange. A line of _ author _ = "author" header is automatically generated and input code: print "Hello word! ", Click" Run "in the menu.

3. install other Python libraries

Note: 1. for all third-party libraries that have been installed separately, if the library directory after installation is not specified, it will be saved to % PYTHON_HOME % \ Lib \ site-packages by default; 2. python is case sensitive and the module name is the same. 3. Crypto provides common encryption and decryption algorithms, such as RSA, RC4, DSA, and DES.

3.1 install setuptools

1, the official website is recommended to use 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, upload the installation directory of pythonand execute the operation python.exe ez_setup.py.

Worker executable file.

3.2 install Pip

1. Installation in Windows

Execute easy_install.exe pipnow in the script of the pythoninstallation directory under the command line (Installation Wizard). After the installation is complete, you can see pip.exe under scripts.

 

2. Installation in Linux

Pip is a tool for installing and managing python packages. The installation procedure is as follows (web site http://www.pip-installer.org/en/latest/installing.html ):

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 a connection (otherwise, an error is reported indicating "the command does not exist ")

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

Note: If the error message "ln: creating symbolic link '/usr/bin/pip': File exists" is displayed during connection, you must manually delete the pip File and then perform the soft connection operation again, after the operation is complete, you can use ll for Connection check

 

3.3 install the SSH module in windows (paramiko + pycrypto + ecdsa)

1. Install pyCrypto

Installing this is troublesome and requires local compilation. To install vs or gcc, there are a bunch of configurations, which may not necessarily be compiled successfully. We recommend that you download the compiled version: http://www.voidspace.org.uk/python/modules.shtml?pycryptoto download it and install it now.

2. Install ecdsa

When executing the command, the system prompts that the ecdsa module cannot be found. Download: https://pypi.python.org/pypi/ecdsa/0.9, unzip to a directory with a setup. py. In windows, run python setup. py install directly in the decompressed directory.

3. Install paramiko

For the ecdsa installation type, download: External. Run python setup. py install directly in the decompressed directory.

3.4 install fabric

1. Installation in Windows

Run the command pip install fabric in command line (cmd) and prompt OK, which may cause unable to find vcvarsall. bat, according to the following solution to solve this problem, delete the installed files and run the command again, the folder fabric and Fabric-1.10.0-py2.7.egg-info under the "Python \ Lib \ site-packages" folder.

2. Installation in Linux

(1) execute the installation command

Pip install fabric

(2) create a connection (otherwise, an error is reported indicating "the command does not exist ")

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

Note: Many lib libraries are used during python development. The installation method is the same as that of fabric. You can use Pip for installation.

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

Because no python environment variable is configured, configure it.

4.2 expansion problem unable to find vcvarsall. bat

When Pip is used to install a library, the system reports "unable to find vcvarsall. bat, you can search msvc9compiler In the python installation path. modify the MSVCCompiler function vc_env = query_vcvarsall (VERSION, plat_spec) to vc_env = query_vcvarsall (8.0, plat_spec), or add version = 8.0 before the function find_vcvarsall (version ).

Note: Find the VS directory in the Registry and find vcvarsall in the vs directory. bat, but the default value in python is vc9.0, that is, vs2008. Therefore, it cannot find the key value in the Registry and returns None,

Productdir = Reg. get_value (r "% s/Setup/VC" % vsbase, "productdir ")

Vsbase value: Software/Microsoft/VisualStudio/9.0

In msvc9compiler. py, def find_vcvarsall (version) is used to find the vcvarsall. bat version, which is the version number, which is actually 9.0.

Vc_env = query_vcvarsall (VERSION, plat_spec), VERSION = get_build_version () Because python32 is built by vc9.0, the VERSION is 9.0.

4.3 error in executing fab command pkg_resources.DistributionNotFound: ecdsa> = 0.11

Install the ssh Module

4.4 Python error: SyntaxError: Non-ASCII character '\ xe5'

Cause: Python uses ASCII encoding by default. If your Python source code contains Chinese characters and other characters, an error is returned.

Solution: 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 code)

4.5 compilation error IndentationError: expected an indented block

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

The following error occurs during compilation: IndentationError: expected an indented block indicates that indentation is required. You only need to press spaces or tabs on the row where the error occurs (but cannot be mixed) the key is indented.

5. Common commands

Multi-line comment: select the line to be commented, CTRL +/

Uncomment multiple lines: select the line to uncomment, CTRL +/

View the method. Press Ctrl and click the function name to view the type of the function-defined 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 Installation Problems

Version error. The next version is a good one. Install it again.

Installing the python Platform

After the download, there are three files, one pys60 platform program, one pys60 interpreter, and the other popular module plug-in (this non-Nokia official file requires self-Signed installation ).

After the platform is installed, it will only be displayed in the program manager on the mobile phone, and will not be displayed in the menu. the platform itself does not have any functions. install the interpreter. A python icon is displayed in the menu. click to run the interpreter. as a software under the development platform, it is recommended to install the interpreter. If you only install the platform to use other software, the interpreter is not required.

We can understand the platform in this way. It is like a game simulator. It is installed with a simulator and can play a variety of games. The simulator itself is not a game that can be played. The game needs a simulator to support and run it.

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.