Learn python-day1 from scratch

Source: Internet
Author: User

First, the installation of Linux system.


I plan to install the centos6.x version to learn python. The "Http://ftp.isu.edu.tw/pub/Linux/CentOS/6.8/isos/x86_64/CentOS-6.8-x86_64-bin-DVD2.iso" of the CentOS system. specific system installation steps are not described in detail.

problem : The installation process encountered a virtual machine error error processing drive because the virtual machine allocated memory too small cause the system installation cannot continue to adjust the size of the memory will be 512M to the appropriate size.


Second, upgrade installation Python2.7.9

1. xz -d python-2.7.9.tar.xz       #将xz格式解压缩  ====> python-2.7.9.tar2. tar xf python-2.7.9.tar         #打开归档        ====>Python-2.7.9  into catalog 3. cd python-2.7.9                    ./ configure --prefix=/usr/local/python2.7.9       #安装三步骤    make   &&  make install  (Remember to use echo $ check)     4.  ln -s /usr/bin/python /usr/bin/python2.4.3                                   #将旧版本python链接到别的地方     ln -s /usr/local/ Python2.7.9/bin/python /usr/bin/python                     #将升级的python链接成为python      5.  vim /usr/bin/ Yum replaces Python with python2.4.3        #目的是使yum能够在旧的Python环境下继续使用


Third, installation Setuptools

1.  cd /usr/local/python2.7.9                           #进入到Python的安装目录下去2 .   tar xf setuptools-2.0.tar.gz                        #解压缩setuptools3 .  cd  setuptools-2.0                                  # Go to the Setuptools directory 4.  python setup.py build                                #编译 (echo $ check) 5.  python setup.py install                            # Installation

· problems encountered : Runtimeerror:compression requires the (missing) zlib module

copying setuptools.egg-info/zip-safe -> build/bdist.linux-i686/egg/egg-infocreating  distcreating  ' Dist/setuptools-2.0-py2.7.egg '  and adding  ' Build/bdist.linux-i686/egg '   to ittraceback  (most recent call last):  file  "setup.py",  line  200, in <module>    dist = setuptools.setup (**setup_params )   File  "/usr/local/python27/lib/python2.7/distutils/core.py",  line 151, in  setup    dist.run_commands ()   File  "/usr/local/python27/lib/python2.7 /distutils/dist.py ",  line 953, in run_commands    self.run_command (cmd )   File  "/usr/local/python27/lib/python2.7/distutils/dist.py",  line 972, in  run_command    cmd_obj.run ()   File  "/usr/local/python27/ Setuptools-2.0/setuptools/command/instaLl.py ",  line 73, in run    self.do_egg_install ()   File  "/usr/local/python27/setuptools-2.0/setuptools/command/install.py",  line 93, in do_egg_ Install    self.run_command (' Bdist_egg ')   File  "/usr/local/python27/lib/ python2.7/distutils/cmd.py ", line 326, in run_command     Self.distribution.run_command (command)   File  "/usr/local/python27/lib/python2.7/distutils/ Dist.py ",  line 972, in run_command    cmd_obj.run ()   File   "/usr/local/python27/setuptools-2.0/setuptools/command/bdist_egg.py", line 246, in  Run    dry_run=self.dry_run, mode=self.gen_header ())   File  "/usr/local /python27/setuptools-2.0/setuptools/command/bdist_egg.py ", line 545, in make_zipfile     z = zipfilE.zipfile (zip_filename, mode, compression=compression)   File  "/usr/local/python27/lib /python2.7/zipfile.py ", line 736, in __init__    " Compression  requires the  (missing)  zlib module "runtimeerror: compression requires the   (missing)  zlib module

     Workaround:  

Yum install -y zlib zlib-devel after the installation is complete, recompile  python2.7 "Do not need to delete, only need to recompile, make, install on the line" in the execution of Python  setup.py install  can be installed successfully. [[email protected] setuptools-2.0]# python setup.py install running  installrunning bdist_eggrunning egg_infowriting requirements to setuptools.egg-info/ requires.txtwriting setuptools.egg-info/pkg-infowriting top-level names to  Setuptools.egg-info/top_level.txtwriting dependency_links to setuptools.egg-info/dependency_ Links.txtwriting entry points to setuptools.egg-info/entry_points.txtreading manifest  file  ' setuptools.egg-info/sources.txt ' reading manifest template  ' manifest.in ' writing  manifest file  ' Setuptools.egg-info/sources.txt ' installing library code to  Build/bdist.linux-i686/eggrunning install_librunning build_pycopying setuptools.egg-inFo/pkg-info -> build/bdist.linux-i686/egg/egg-infocopying setuptools.egg-info/sources.txt  -> build/bdist.linux-i686/egg/egg-infocopying setuptools.egg-info/dependency_links.txt  -> build/bdist.linux-i686/egg/egg-infocopying setuptools.egg-info/entry_points.txt - > build/bdist.linux-i686/egg/EGG-INFOcopying setuptools.egg-info/requires.txt ->  build/bdist.linux-i686/egg/egg-infocopying setuptools.egg-info/top_level.txt -> build/ bdist.linux-i686/egg/egg-infocreating  ' Dist/setuptools-2.0-py2.7.egg '  and adding  ' build/ Bdist.linux-i686/egg '  to itremoving  ' Build/bdist.linux-i686/egg '   (and everything  under it) processing setuptools-2.0-py2.7.eggcopying setuptools-2.0-py2.7.egg to  /usr/local/python27/lib/python2.7/site-packagesAdding setuptools 2.0 to  Easy-install.pth fileinstalling easy_install script to /usr/local/python27/bininstalling easy_install-2.7 script to / usr/local/python27/bininstalled /usr/local/python27/lib/python2.7/site-packages/ Setuptools-2.0-py2.7.eggprocessing dependencies for setuptools==2.0finished processing  dependencies for setuptools==2.0[[email protected] setuptools-2.0]# echo $ ? 0[[email protected] setuptools-2.0]#


Four, install PIP.

1.cd/usr/local/python2.7.9/directory, install match (Install package: pip-8.1.2.tar.gz)

· problem encountered : Importerror:cannot Import name Httpshandler

Workaround: yum install -y  openssl openssl-devel       After the installation is complete, recompile  python2.7 "Do not need to delete, only need to recompile, make, install on the line" in the execution of python setup.py install  can be installed successfully. The        test is as follows: [[Email protected] pip-8.1.2]# /usr/local/python27/bin /pip install flask collecting flask  downloading  flask-0.11.1-py2.py3-none-any.whl  (80kB)     100% |############################## ##| 81kb 395kb/s collecting werkzeug>=0.7  (From flask)   Downloading  Werkzeug-0.11.11-py2.py3-none-any.whl  (306kB)     100% |################### #############| 307kb 870kb/s collecting jinja2>=2.4  (From flask)    downloading jinja2-2.8-py2.py3-none-any.whl  (263kB)     100% |############## ##################| 266kb 1.0mb/s  collecting click>=2.0  (From flask)   Downloading click-6.6.tar.gz  (283kB)     100% |################################| 286kb 1.2mb/s collecting  itsdangerous>=0.21  (From flask)   Downloading itsdangerous-0.24.tar.gz  ( 46kB)     100% |################################| 51kB 2.6MB/s  collecting markupsafe  (From jinja2>=2.4->flask)   Downloading  MARKUPSAFE-0.23.TAR.GZINSTALLING&NBSP;COLLECTED&NBSP;PACKAGES:&NBSP;WERKZEUG,&NBSP;MARKUPSAFE,&NBSP;JINJA2,  click, itsdangerous, flask  Running setup.py install for  markupsafe ... done  running setup.py install for click ...  Done  running setup.py install for itsdangerous ... donesuccessfully  installed jinja2-2.8 markupsafe-0.23 werkzeug-0.11.11 click-6.6 flask-0.11.1 itsdangerous-0.24 


V. Installing Ipython with PIP

Use the PIP command to install IPYTHON:PIP install Ipython

Use of PIP command: The use of PIP: http://www.ttlsa.com/python/how-to-install-and-use-pip-ttlsa/

[[email protected] ~]# pip --help usage:     pip < command> [options]commands:  install                      Install packages.   download                     Download packages.  uninstall                    uninstall packages.  freeze                        Output installed packages in requirements format.   list                         list installed packages.  show                         show  information about installed packages.  search                       search  PyPI for packages.  wheel                        Build wheels  from your requirements.  hash                         Compute hashes  of package archives.  completion                   a helper command used for command completion  help                          show help for commands. general options:  -h, --help                   Show help.  --isolated                   Run pip in  an isolated mode, ignoring environment variables and user                                configuration.  -v, --verbose                give more output. option is additive, and can  be used up to 3 times.  -v, --version                show version and exit.  - q, --quiet                  Give less output.  --log <path>                 path to a verbose appending  log.  --proxy <proxy>              specify a proxy in the form [user:[email protected]] proxy.server:port.  --retries <retries>          Maximum number of retries each connection should attempt  (default 5                                times) .  --timeout <sec>              set the socket timeout   (default 15 seconds) .  --exists-action <action>     default action when a path already exists:  (s) witch,  (i) gnore,  (w ) ipe,                                (b) ackup.  -- Trusted-host 





This article from "11931192" blog, declined reprint!

Learn python-day1 from scratch

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.