воскресенье, 5 мая 2013 г.

Установка Python

Скачать Python можно с сайта:

http://www.python.org/download/

Устанавливать из архива с исходными кодами примерно так:

tar xvfj  Python-3.3.1.tar.bz2
cd  Python-3.3.1
./configure
make
make test
make install


Или для локальной установки с префиксом:

./configure  --prefix=$HOME/local/python3
make
make test
make install

ln -s ~/local/python3/bin/python3.3 ~/bin/python3
ln -s ~/local/python3/bin/idle      ~/bin/idle3


Для Windows прописываем в переменную PATH путь C:\Python33\

C:\Users\angor>cd c:\projects

c:\projects>python -V
Python 3.3.1

После установки Python желательно установить пакет Distribute.
Описание смотрим на packages.python.org/distribute.
Его потребует менеджер пакетов PIP.

Устанавливаем его так:

Скачиваем скрипт:

curl -O http://python-distribute.org/distribute_setup.py

или

wget http://python-distribute.org/distribute_setup.py

c:\projects>wget http://python-distribute.org/distribute_setup.py

SYSTEM_WGETRC = c:/progra~1/wget/etc/wgetrc
syswgetrc = C:\Program Files (x86)\GnuWin32/etc/wgetrc
--2013-05-05 23:27:22--  http://python-distribute.org/distribute_setup.py
Распознаётся python-distribute.org... 88.191.140.69
Устанавливается соединение с python-distribute.org|88.191.140.69|:80... соединение установлено.
Запрос HTTP послан, ожидается ответ... 200 OK
Длина: 17319 (17K) [text/x-python]
Сохраняется в каталог: `distribute_setup.py'.

100%[==============================================================================>] 17 319      --.-K/s   в 0,001s

2013-05-05 23:27:22 (15,2 MB/s) - `distribute_setup.py' сохранён [17319/17319]

и далее запускаем  его:

c:\projects>python distribute_setup.py

Downloading http://pypi.python.org/packages/source/d/distribute/distribute-0.6.38.tar.gz
Extracting in c:\users\angor\appdata\local\temp\tmpe0haa8
Now working in c:\users\angor\appdata\local\temp\tmpe0haa8\distribute-0.6.38
Installing Distribute
creating build
creating build\src
creating build\src\_markerlib
creating build\src\docs
creating build\src\docs\_templates
creating build\src\docs\_theme
creating build\src\docs\_theme\nature
creating build\src\docs\_theme\nature\static
creating build\src\docs\build
creating build\src\docs\build\html
creating build\src\docs\build\html\_sources
creating build\src\docs\build\html\_static
creating build\src\setuptools
creating build\src\setuptools\command
creating build\src\setuptools\tests
creating build\src\setuptools\tests\indexes
creating build\src\setuptools\tests\indexes\test_links_priority
creating build\src\setuptools\tests\indexes\test_links_priority\simple
creating build\src\setuptools\tests\indexes\test_links_priority\simple\foobar
creating build\src\tests
creating build\src\tests\shlib_test
copying setuptools\archive_util.py -> build\src\setuptools
copying setuptools\depends.py -> build\src\setuptools
copying setuptools\dist.py -> build\src\setuptools
copying setuptools\extension.py -> build\src\setuptools
copying setuptools\package_index.py -> build\src\setuptools
copying setuptools\sandbox.py -> build\src\setuptools
copying setuptools\script template (dev).py -> build\src\setuptools
copying setuptools\script template.py -> build\src\setuptools
copying setuptools\__init__.py -> build\src\setuptools
copying setuptools\tests\doctest.py -> build\src\setuptools\tests
copying setuptools\tests\py26compat.py -> build\src\setuptools\tests
copying setuptools\tests\server.py -> build\src\setuptools\tests
copying setuptools\tests\test_bdist_egg.py -> build\src\setuptools\tests
copying setuptools\tests\test_build_ext.py -> build\src\setuptools\tests
copying setuptools\tests\test_develop.py -> build\src\setuptools\tests
copying setuptools\tests\test_dist_info.py -> build\src\setuptools\tests
copying setuptools\tests\test_easy_install.py -> build\src\setuptools\tests
copying setuptools\tests\test_markerlib.py -> build\src\setuptools\tests
copying setuptools\tests\test_packageindex.py -> build\src\setuptools\tests
copying setuptools\tests\test_resources.py -> build\src\setuptools\tests
copying setuptools\tests\test_sandbox.py -> build\src\setuptools\tests
copying setuptools\tests\test_sdist.py -> build\src\setuptools\tests
copying setuptools\tests\test_test.py -> build\src\setuptools\tests
copying setuptools\tests\test_upload_docs.py -> build\src\setuptools\tests
copying setuptools\tests\__init__.py -> build\src\setuptools\tests
copying setuptools\command\alias.py -> build\src\setuptools\command
copying setuptools\command\bdist_egg.py -> build\src\setuptools\command
copying setuptools\command\bdist_rpm.py -> build\src\setuptools\command
copying setuptools\command\bdist_wininst.py -> build\src\setuptools\command
copying setuptools\command\build_ext.py -> build\src\setuptools\command
copying setuptools\command\build_py.py -> build\src\setuptools\command
copying setuptools\command\develop.py -> build\src\setuptools\command
copying setuptools\command\easy_install.py -> build\src\setuptools\command
copying setuptools\command\egg_info.py -> build\src\setuptools\command
copying setuptools\command\install.py -> build\src\setuptools\command
copying setuptools\command\install_egg_info.py -> build\src\setuptools\command
copying setuptools\command\install_lib.py -> build\src\setuptools\command
copying setuptools\command\install_scripts.py -> build\src\setuptools\command
copying setuptools\command\register.py -> build\src\setuptools\command
copying setuptools\command\rotate.py -> build\src\setuptools\command
copying setuptools\command\saveopts.py -> build\src\setuptools\command
copying setuptools\command\sdist.py -> build\src\setuptools\command
copying setuptools\command\setopt.py -> build\src\setuptools\command
copying setuptools\command\test.py -> build\src\setuptools\command
copying setuptools\command\upload.py -> build\src\setuptools\command
copying setuptools\command\upload_docs.py -> build\src\setuptools\command
copying setuptools\command\__init__.py -> build\src\setuptools\command
copying setuptools\tests\win_script_wrapper.txt -> build\src\setuptools\tests
copying setuptools\cli-32.exe -> build\src\setuptools
copying setuptools\cli-64.exe -> build\src\setuptools
copying setuptools\cli.exe -> build\src\setuptools
copying setuptools\gui-32.exe -> build\src\setuptools
copying setuptools\gui-64.exe -> build\src\setuptools
copying setuptools\gui.exe -> build\src\setuptools
copying setuptools\command\launcher manifest.xml -> build\src\setuptools\command
copying tests\install_test.py -> build\src\tests
copying tests\manual_test.py -> build\src\tests
copying tests\test_distribute_setup.py -> build\src\tests
copying tests\shlib_test\setup.py -> build\src\tests\shlib_test
copying tests\shlib_test\test_hello.py -> build\src\tests\shlib_test
copying tests\shlib_test\hello.c -> build\src\tests\shlib_test
copying tests\shlib_test\hellolib.c -> build\src\tests\shlib_test
copying tests\shlib_test\hello.pyx -> build\src\tests\shlib_test
copying tests\api_tests.txt -> build\src\tests
RefactoringTool: Skipping implicit fixer: buffer
RefactoringTool: Skipping implicit fixer: idioms
RefactoringTool: Skipping implicit fixer: set_literal
RefactoringTool: Skipping implicit fixer: ws_comma
RefactoringTool: Refactored build\src\tests\api_tests.txt
--- build\src\tests\api_tests.txt       (original)
+++ build\src\tests\api_tests.txt       (refactored)
@@ -39,7 +39,7 @@
     >>> dist.py_version == sys.version[:3]
     True

-    >>> print dist.platform
+    >>> print(dist.platform)
     None

 Including various computed attributes::
@@ -199,7 +199,7 @@
 You can ask a WorkingSet to ``find()`` a distribution matching a requirement::

     >>> from pkg_resources import Requirement
-    >>> print ws.find(Requirement.parse("Foo==1.0"))    # no match, return None
+    >>> print(ws.find(Requirement.parse("Foo==1.0")))    # no match, return None
     None

     >>> ws.find(Requirement.parse("Bar==0.9"))  # match, return distribution
@@ -211,7 +211,7 @@
     >>> try:
     ...     ws.find(Requirement.parse("Bar==1.0"))
     ... except VersionConflict:
-    ...     print 'ok'
+    ...     print('ok')
     ok

 You can subscribe a callback function to receive notifications whenever a new
@@ -219,7 +219,7 @@
 once for each existing distribution in the working set, and then is called
 again for new distributions added thereafter::

-    >>> def added(dist): print "Added", dist
+    >>> def added(dist): print("Added", dist)
     >>> ws.subscribe(added)
     Added Bar 0.9
     >>> foo12 = Distribution(project_name="Foo", version="1.2", location="f12")
RefactoringTool: Files that were modified:
RefactoringTool: build\src\tests\api_tests.txt
copying setuptools\tests\indexes\test_links_priority\external.html -> build\src\setuptools\tests\indexes\test_links_prio
rity
copying setuptools\tests\indexes\test_links_priority\simple\foobar\index.html -> build\src\setuptools\tests\indexes\test
_links_priority\simple\foobar
copying docs\conf.py -> build\src\docs
copying docs\easy_install.txt -> build\src\docs
copying docs\index.txt -> build\src\docs
copying docs\pkg_resources.txt -> build\src\docs
copying docs\python3.txt -> build\src\docs
copying docs\roadmap.txt -> build\src\docs
copying docs\setuptools.txt -> build\src\docs
copying docs\using.txt -> build\src\docs
copying docs\build\html\_sources\easy_install.txt -> build\src\docs\build\html\_sources
copying docs\build\html\_sources\index.txt -> build\src\docs\build\html\_sources
copying docs\build\html\_sources\pkg_resources.txt -> build\src\docs\build\html\_sources
copying docs\build\html\_sources\python3.txt -> build\src\docs\build\html\_sources
copying docs\build\html\_sources\roadmap.txt -> build\src\docs\build\html\_sources
copying docs\build\html\_sources\setuptools.txt -> build\src\docs\build\html\_sources
copying docs\build\html\_sources\using.txt -> build\src\docs\build\html\_sources
copying docs\_theme\nature\theme.conf -> build\src\docs\_theme\nature
copying docs\_theme\nature\static\pygments.css -> build\src\docs\_theme\nature\static
copying docs\build\html\_static\basic.css -> build\src\docs\build\html\_static
copying docs\build\html\_static\nature.css -> build\src\docs\build\html\_static
copying docs\build\html\_static\pygments.css -> build\src\docs\build\html\_static
copying docs\_theme\nature\static\nature.css_t -> build\src\docs\_theme\nature\static
copying docs\Makefile -> build\src\docs
copying docs\_templates\indexsidebar.html -> build\src\docs\_templates
copying _markerlib\markers.py -> build\src\_markerlib
copying _markerlib\__init__.py -> build\src\_markerlib
copying distribute_setup.py -> build\src
copying easy_install.py -> build\src
copying pkg_resources.py -> build\src
copying release.py -> build\src
copying setup.py -> build\src
copying site.py -> build\src
copying CHANGES.txt -> build\src
copying CONTRIBUTORS.txt -> build\src
copying DEVGUIDE.txt -> build\src
copying README.txt -> build\src
copying MANIFEST.in -> build\src
copying launcher.c -> build\src
Skipping implicit fixer: buffer
Skipping implicit fixer: idioms
Skipping implicit fixer: set_literal
Skipping implicit fixer: ws_comma
Before install bootstrap.
Scanning installed packages
No setuptools distribution found
running install
running bdist_egg
running egg_info
writing top-level names to distribute.egg-info\top_level.txt
writing dependency_links to distribute.egg-info\dependency_links.txt
writing distribute.egg-info\PKG-INFO
writing entry points to distribute.egg-info\entry_points.txt
reading manifest file 'distribute.egg-info\SOURCES.txt'
reading manifest template 'MANIFEST.in'
writing manifest file 'distribute.egg-info\SOURCES.txt'
installing library code to build\bdist.win-amd64\egg
running install_lib
running build_py
creating build\lib
copying build\src\pkg_resources.py -> build\lib
copying build\src\easy_install.py -> build\lib
copying build\src\site.py -> build\lib
creating build\lib\setuptools
copying build\src\setuptools\archive_util.py -> build\lib\setuptools
copying build\src\setuptools\depends.py -> build\lib\setuptools
copying build\src\setuptools\dist.py -> build\lib\setuptools
copying build\src\setuptools\extension.py -> build\lib\setuptools
copying build\src\setuptools\package_index.py -> build\lib\setuptools
copying build\src\setuptools\sandbox.py -> build\lib\setuptools
copying build\src\setuptools\script template (dev).py -> build\lib\setuptools
copying build\src\setuptools\script template.py -> build\lib\setuptools
copying build\src\setuptools\__init__.py -> build\lib\setuptools
creating build\lib\_markerlib
copying build\src\_markerlib\markers.py -> build\lib\_markerlib
copying build\src\_markerlib\__init__.py -> build\lib\_markerlib
creating build\lib\setuptools\command
copying build\src\setuptools\command\alias.py -> build\lib\setuptools\command
copying build\src\setuptools\command\bdist_egg.py -> build\lib\setuptools\command
copying build\src\setuptools\command\bdist_rpm.py -> build\lib\setuptools\command
copying build\src\setuptools\command\bdist_wininst.py -> build\lib\setuptools\command
copying build\src\setuptools\command\build_ext.py -> build\lib\setuptools\command
copying build\src\setuptools\command\build_py.py -> build\lib\setuptools\command
copying build\src\setuptools\command\develop.py -> build\lib\setuptools\command
copying build\src\setuptools\command\easy_install.py -> build\lib\setuptools\command
copying build\src\setuptools\command\egg_info.py -> build\lib\setuptools\command
copying build\src\setuptools\command\install.py -> build\lib\setuptools\command
copying build\src\setuptools\command\install_egg_info.py -> build\lib\setuptools\command
copying build\src\setuptools\command\install_lib.py -> build\lib\setuptools\command
copying build\src\setuptools\command\install_scripts.py -> build\lib\setuptools\command
copying build\src\setuptools\command\register.py -> build\lib\setuptools\command
copying build\src\setuptools\command\rotate.py -> build\lib\setuptools\command
copying build\src\setuptools\command\saveopts.py -> build\lib\setuptools\command
copying build\src\setuptools\command\sdist.py -> build\lib\setuptools\command
copying build\src\setuptools\command\setopt.py -> build\lib\setuptools\command
copying build\src\setuptools\command\test.py -> build\lib\setuptools\command
copying build\src\setuptools\command\upload.py -> build\lib\setuptools\command
copying build\src\setuptools\command\upload_docs.py -> build\lib\setuptools\command
copying build\src\setuptools\command\__init__.py -> build\lib\setuptools\command
creating build\lib\setuptools\tests
copying build\src\setuptools\tests\doctest.py -> build\lib\setuptools\tests
copying build\src\setuptools\tests\py26compat.py -> build\lib\setuptools\tests
copying build\src\setuptools\tests\server.py -> build\lib\setuptools\tests
copying build\src\setuptools\tests\test_bdist_egg.py -> build\lib\setuptools\tests
copying build\src\setuptools\tests\test_build_ext.py -> build\lib\setuptools\tests
copying build\src\setuptools\tests\test_develop.py -> build\lib\setuptools\tests
copying build\src\setuptools\tests\test_dist_info.py -> build\lib\setuptools\tests
copying build\src\setuptools\tests\test_easy_install.py -> build\lib\setuptools\tests
copying build\src\setuptools\tests\test_markerlib.py -> build\lib\setuptools\tests
copying build\src\setuptools\tests\test_packageindex.py -> build\lib\setuptools\tests
copying build\src\setuptools\tests\test_resources.py -> build\lib\setuptools\tests
copying build\src\setuptools\tests\test_sandbox.py -> build\lib\setuptools\tests
copying build\src\setuptools\tests\test_sdist.py -> build\lib\setuptools\tests
copying build\src\setuptools\tests\test_test.py -> build\lib\setuptools\tests
copying build\src\setuptools\tests\test_upload_docs.py -> build\lib\setuptools\tests
copying build\src\setuptools\tests\__init__.py -> build\lib\setuptools\tests
copying build\src\setuptools\cli-32.exe -> build\lib\setuptools
copying build\src\setuptools\cli-64.exe -> build\lib\setuptools
copying build\src\setuptools\cli.exe -> build\lib\setuptools
copying build\src\setuptools\gui-32.exe -> build\lib\setuptools
copying build\src\setuptools\gui-64.exe -> build\lib\setuptools
copying build\src\setuptools\gui.exe -> build\lib\setuptools
copying build\src\setuptools\command\launcher manifest.xml -> build\lib\setuptools\command
creating build\bdist.win-amd64
creating build\bdist.win-amd64\egg
copying build\lib\easy_install.py -> build\bdist.win-amd64\egg
copying build\lib\pkg_resources.py -> build\bdist.win-amd64\egg
creating build\bdist.win-amd64\egg\setuptools
copying build\lib\setuptools\archive_util.py -> build\bdist.win-amd64\egg\setuptools
copying build\lib\setuptools\cli-32.exe -> build\bdist.win-amd64\egg\setuptools
copying build\lib\setuptools\cli-64.exe -> build\bdist.win-amd64\egg\setuptools
copying build\lib\setuptools\cli.exe -> build\bdist.win-amd64\egg\setuptools
creating build\bdist.win-amd64\egg\setuptools\command
copying build\lib\setuptools\command\alias.py -> build\bdist.win-amd64\egg\setuptools\command
copying build\lib\setuptools\command\bdist_egg.py -> build\bdist.win-amd64\egg\setuptools\command
copying build\lib\setuptools\command\bdist_rpm.py -> build\bdist.win-amd64\egg\setuptools\command
copying build\lib\setuptools\command\bdist_wininst.py -> build\bdist.win-amd64\egg\setuptools\command
copying build\lib\setuptools\command\build_ext.py -> build\bdist.win-amd64\egg\setuptools\command
copying build\lib\setuptools\command\build_py.py -> build\bdist.win-amd64\egg\setuptools\command
copying build\lib\setuptools\command\develop.py -> build\bdist.win-amd64\egg\setuptools\command
copying build\lib\setuptools\command\easy_install.py -> build\bdist.win-amd64\egg\setuptools\command
copying build\lib\setuptools\command\egg_info.py -> build\bdist.win-amd64\egg\setuptools\command
copying build\lib\setuptools\command\install.py -> build\bdist.win-amd64\egg\setuptools\command
copying build\lib\setuptools\command\install_egg_info.py -> build\bdist.win-amd64\egg\setuptools\command
copying build\lib\setuptools\command\install_lib.py -> build\bdist.win-amd64\egg\setuptools\command
copying build\lib\setuptools\command\install_scripts.py -> build\bdist.win-amd64\egg\setuptools\command
copying build\lib\setuptools\command\launcher manifest.xml -> build\bdist.win-amd64\egg\setuptools\command
copying build\lib\setuptools\command\register.py -> build\bdist.win-amd64\egg\setuptools\command
copying build\lib\setuptools\command\rotate.py -> build\bdist.win-amd64\egg\setuptools\command
copying build\lib\setuptools\command\saveopts.py -> build\bdist.win-amd64\egg\setuptools\command
copying build\lib\setuptools\command\sdist.py -> build\bdist.win-amd64\egg\setuptools\command
copying build\lib\setuptools\command\setopt.py -> build\bdist.win-amd64\egg\setuptools\command
copying build\lib\setuptools\command\test.py -> build\bdist.win-amd64\egg\setuptools\command
copying build\lib\setuptools\command\upload.py -> build\bdist.win-amd64\egg\setuptools\command
copying build\lib\setuptools\command\upload_docs.py -> build\bdist.win-amd64\egg\setuptools\command
copying build\lib\setuptools\command\__init__.py -> build\bdist.win-amd64\egg\setuptools\command
copying build\lib\setuptools\depends.py -> build\bdist.win-amd64\egg\setuptools
copying build\lib\setuptools\dist.py -> build\bdist.win-amd64\egg\setuptools
copying build\lib\setuptools\extension.py -> build\bdist.win-amd64\egg\setuptools
copying build\lib\setuptools\gui-32.exe -> build\bdist.win-amd64\egg\setuptools
copying build\lib\setuptools\gui-64.exe -> build\bdist.win-amd64\egg\setuptools
copying build\lib\setuptools\gui.exe -> build\bdist.win-amd64\egg\setuptools
copying build\lib\setuptools\package_index.py -> build\bdist.win-amd64\egg\setuptools
copying build\lib\setuptools\sandbox.py -> build\bdist.win-amd64\egg\setuptools
copying build\lib\setuptools\script template (dev).py -> build\bdist.win-amd64\egg\setuptools
copying build\lib\setuptools\script template.py -> build\bdist.win-amd64\egg\setuptools
creating build\bdist.win-amd64\egg\setuptools\tests
copying build\lib\setuptools\tests\doctest.py -> build\bdist.win-amd64\egg\setuptools\tests
copying build\lib\setuptools\tests\py26compat.py -> build\bdist.win-amd64\egg\setuptools\tests
copying build\lib\setuptools\tests\server.py -> build\bdist.win-amd64\egg\setuptools\tests
copying build\lib\setuptools\tests\test_bdist_egg.py -> build\bdist.win-amd64\egg\setuptools\tests
copying build\lib\setuptools\tests\test_build_ext.py -> build\bdist.win-amd64\egg\setuptools\tests
copying build\lib\setuptools\tests\test_develop.py -> build\bdist.win-amd64\egg\setuptools\tests
copying build\lib\setuptools\tests\test_dist_info.py -> build\bdist.win-amd64\egg\setuptools\tests
copying build\lib\setuptools\tests\test_easy_install.py -> build\bdist.win-amd64\egg\setuptools\tests
copying build\lib\setuptools\tests\test_markerlib.py -> build\bdist.win-amd64\egg\setuptools\tests
copying build\lib\setuptools\tests\test_packageindex.py -> build\bdist.win-amd64\egg\setuptools\tests
copying build\lib\setuptools\tests\test_resources.py -> build\bdist.win-amd64\egg\setuptools\tests
copying build\lib\setuptools\tests\test_sandbox.py -> build\bdist.win-amd64\egg\setuptools\tests
copying build\lib\setuptools\tests\test_sdist.py -> build\bdist.win-amd64\egg\setuptools\tests
copying build\lib\setuptools\tests\test_test.py -> build\bdist.win-amd64\egg\setuptools\tests
copying build\lib\setuptools\tests\test_upload_docs.py -> build\bdist.win-amd64\egg\setuptools\tests
copying build\lib\setuptools\tests\__init__.py -> build\bdist.win-amd64\egg\setuptools\tests
copying build\lib\setuptools\__init__.py -> build\bdist.win-amd64\egg\setuptools
copying build\lib\site.py -> build\bdist.win-amd64\egg
creating build\bdist.win-amd64\egg\_markerlib
copying build\lib\_markerlib\markers.py -> build\bdist.win-amd64\egg\_markerlib
copying build\lib\_markerlib\__init__.py -> build\bdist.win-amd64\egg\_markerlib
byte-compiling build\bdist.win-amd64\egg\easy_install.py to easy_install.cpython-33.pyc
byte-compiling build\bdist.win-amd64\egg\pkg_resources.py to pkg_resources.cpython-33.pyc
byte-compiling build\bdist.win-amd64\egg\setuptools\archive_util.py to archive_util.cpython-33.pyc
byte-compiling build\bdist.win-amd64\egg\setuptools\command\alias.py to alias.cpython-33.pyc
byte-compiling build\bdist.win-amd64\egg\setuptools\command\bdist_egg.py to bdist_egg.cpython-33.pyc
byte-compiling build\bdist.win-amd64\egg\setuptools\command\bdist_rpm.py to bdist_rpm.cpython-33.pyc
byte-compiling build\bdist.win-amd64\egg\setuptools\command\bdist_wininst.py to bdist_wininst.cpython-33.pyc
byte-compiling build\bdist.win-amd64\egg\setuptools\command\build_ext.py to build_ext.cpython-33.pyc
byte-compiling build\bdist.win-amd64\egg\setuptools\command\build_py.py to build_py.cpython-33.pyc
byte-compiling build\bdist.win-amd64\egg\setuptools\command\develop.py to develop.cpython-33.pyc
byte-compiling build\bdist.win-amd64\egg\setuptools\command\easy_install.py to easy_install.cpython-33.pyc
byte-compiling build\bdist.win-amd64\egg\setuptools\command\egg_info.py to egg_info.cpython-33.pyc
byte-compiling build\bdist.win-amd64\egg\setuptools\command\install.py to install.cpython-33.pyc
byte-compiling build\bdist.win-amd64\egg\setuptools\command\install_egg_info.py to install_egg_info.cpython-33.pyc
byte-compiling build\bdist.win-amd64\egg\setuptools\command\install_lib.py to install_lib.cpython-33.pyc
byte-compiling build\bdist.win-amd64\egg\setuptools\command\install_scripts.py to install_scripts.cpython-33.pyc
byte-compiling build\bdist.win-amd64\egg\setuptools\command\register.py to register.cpython-33.pyc
byte-compiling build\bdist.win-amd64\egg\setuptools\command\rotate.py to rotate.cpython-33.pyc
byte-compiling build\bdist.win-amd64\egg\setuptools\command\saveopts.py to saveopts.cpython-33.pyc
byte-compiling build\bdist.win-amd64\egg\setuptools\command\sdist.py to sdist.cpython-33.pyc
byte-compiling build\bdist.win-amd64\egg\setuptools\command\setopt.py to setopt.cpython-33.pyc
byte-compiling build\bdist.win-amd64\egg\setuptools\command\test.py to test.cpython-33.pyc
byte-compiling build\bdist.win-amd64\egg\setuptools\command\upload.py to upload.cpython-33.pyc
byte-compiling build\bdist.win-amd64\egg\setuptools\command\upload_docs.py to upload_docs.cpython-33.pyc
byte-compiling build\bdist.win-amd64\egg\setuptools\command\__init__.py to __init__.cpython-33.pyc
byte-compiling build\bdist.win-amd64\egg\setuptools\depends.py to depends.cpython-33.pyc
byte-compiling build\bdist.win-amd64\egg\setuptools\dist.py to dist.cpython-33.pyc
byte-compiling build\bdist.win-amd64\egg\setuptools\extension.py to extension.cpython-33.pyc
byte-compiling build\bdist.win-amd64\egg\setuptools\package_index.py to package_index.cpython-33.pyc
byte-compiling build\bdist.win-amd64\egg\setuptools\sandbox.py to sandbox.cpython-33.pyc
byte-compiling build\bdist.win-amd64\egg\setuptools\script template (dev).py to script template (dev).cpython-33.pyc
byte-compiling build\bdist.win-amd64\egg\setuptools\script template.py to script template.cpython-33.pyc
byte-compiling build\bdist.win-amd64\egg\setuptools\tests\doctest.py to doctest.cpython-33.pyc
byte-compiling build\bdist.win-amd64\egg\setuptools\tests\py26compat.py to py26compat.cpython-33.pyc
byte-compiling build\bdist.win-amd64\egg\setuptools\tests\server.py to server.cpython-33.pyc
byte-compiling build\bdist.win-amd64\egg\setuptools\tests\test_bdist_egg.py to test_bdist_egg.cpython-33.pyc
byte-compiling build\bdist.win-amd64\egg\setuptools\tests\test_build_ext.py to test_build_ext.cpython-33.pyc
byte-compiling build\bdist.win-amd64\egg\setuptools\tests\test_develop.py to test_develop.cpython-33.pyc
byte-compiling build\bdist.win-amd64\egg\setuptools\tests\test_dist_info.py to test_dist_info.cpython-33.pyc
byte-compiling build\bdist.win-amd64\egg\setuptools\tests\test_easy_install.py to test_easy_install.cpython-33.pyc
byte-compiling build\bdist.win-amd64\egg\setuptools\tests\test_markerlib.py to test_markerlib.cpython-33.pyc
byte-compiling build\bdist.win-amd64\egg\setuptools\tests\test_packageindex.py to test_packageindex.cpython-33.pyc
byte-compiling build\bdist.win-amd64\egg\setuptools\tests\test_resources.py to test_resources.cpython-33.pyc
byte-compiling build\bdist.win-amd64\egg\setuptools\tests\test_sandbox.py to test_sandbox.cpython-33.pyc
byte-compiling build\bdist.win-amd64\egg\setuptools\tests\test_sdist.py to test_sdist.cpython-33.pyc
byte-compiling build\bdist.win-amd64\egg\setuptools\tests\test_test.py to test_test.cpython-33.pyc
byte-compiling build\bdist.win-amd64\egg\setuptools\tests\test_upload_docs.py to test_upload_docs.cpython-33.pyc
byte-compiling build\bdist.win-amd64\egg\setuptools\tests\__init__.py to __init__.cpython-33.pyc
byte-compiling build\bdist.win-amd64\egg\setuptools\__init__.py to __init__.cpython-33.pyc
byte-compiling build\bdist.win-amd64\egg\site.py to site.cpython-33.pyc
byte-compiling build\bdist.win-amd64\egg\_markerlib\markers.py to markers.cpython-33.pyc
byte-compiling build\bdist.win-amd64\egg\_markerlib\__init__.py to __init__.cpython-33.pyc
creating build\bdist.win-amd64\egg\EGG-INFO
copying distribute.egg-info\PKG-INFO -> build\bdist.win-amd64\egg\EGG-INFO
copying distribute.egg-info\SOURCES.txt -> build\bdist.win-amd64\egg\EGG-INFO
copying distribute.egg-info\dependency_links.txt -> build\bdist.win-amd64\egg\EGG-INFO
copying distribute.egg-info\entry_points.txt -> build\bdist.win-amd64\egg\EGG-INFO
copying distribute.egg-info\top_level.txt -> build\bdist.win-amd64\egg\EGG-INFO
copying distribute.egg-info\zip-safe -> build\bdist.win-amd64\egg\EGG-INFO
creating dist
creating 'dist\distribute-0.6.38-py3.3.egg' and adding 'build\bdist.win-amd64\egg' to it
removing 'build\bdist.win-amd64\egg' (and everything under it)
Processing distribute-0.6.38-py3.3.egg
creating c:\python33\lib\site-packages\distribute-0.6.38-py3.3.egg
Extracting distribute-0.6.38-py3.3.egg to c:\python33\lib\site-packages
Adding distribute 0.6.38 to easy-install.pth file
Installing easy_install-script.py script to C:\Python33\Scripts
Installing easy_install.exe script to C:\Python33\Scripts
Installing easy_install-3.3-script.py script to C:\Python33\Scripts
Installing easy_install-3.3.exe script to C:\Python33\Scripts

Installed c:\python33\lib\site-packages\distribute-0.6.38-py3.3.egg
Processing dependencies for distribute==0.6.38
Finished processing dependencies for distribute==0.6.38
After install bootstrap.
Creating C:\Python33\Lib\site-packages\setuptools-0.6c11-py3.3.egg-info
Creating C:\Python33\Lib\site-packages\setuptools.pth

c:\projects>

После этого в каталоге  C:\Python33\Scripts\
появится утилита  easy_install

Далее прописываем в переменную PATH путь C:\Python33\Scripts\

Проверяем версию  easy_install:

c:\projects>easy_install --version

distribute 0.6.38

c:\projects>

и устанавливаем менеджер пакетов PIP с помощью easy_install:

c:\projects>easy_install pip

Searching for pip
Reading http://pypi.python.org/simple/pip/
Reading http://www.pip-installer.org
Reading http://pip.openplans.org
Best match: pip 1.3.1
Downloading http://pypi.python.org/packages/source/p/pip/pip-1.3.1.tar.gz#md5=cbb27a191cebc58997c4da8513863153
Processing pip-1.3.1.tar.gz
Writing c:\users\angor\appdata\local\temp\easy_install-znorvx\pip-1.3.1\setup.cfg
Running pip-1.3.1\setup.py -q bdist_egg --dist-dir c:\users\angor\appdata\local\temp\easy_install-znorvx\pip-1.3.1\egg-d
ist-tmp-5hfmrt
warning: no files found matching '*.html' under directory 'docs'
warning: no previously-included files matching '*.txt' found under directory 'docs\_build'
no previously-included directories found matching 'docs\_build\_sources'
Adding pip 1.3.1 to easy-install.pth file
Installing pip-3.3-script.py script to C:\Python33\Scripts
Installing pip-3.3.exe script to C:\Python33\Scripts
Installing pip-script.py script to C:\Python33\Scripts
Installing pip.exe script to C:\Python33\Scripts

Installed c:\python33\lib\site-packages\pip-1.3.1-py3.3.egg
Processing dependencies for pip
Finished processing dependencies for pip

c:\projects>

c:\projects>pip -V

pip 1.3.1 from c:\python33\lib\site-packages\pip-1.3.1-py3.3.egg (python 3.3)

c:\projects>


PIP  можно также установить и из архива с исходными кодами:

c:\projects>wget http://pypi.python.org/packages/source/p/pip/pip-1.3.1.tar.gz

SYSTEM_WGETRC = c:/progra~1/wget/etc/wgetrc
syswgetrc = C:\Program Files (x86)\GnuWin32/etc/wgetrc
--2013-05-06 00:18:05--  http://pypi.python.org/packages/source/p/pip/pip-1.3.1.tar.gz
Распознаётся pypi.python.org... 140.211.10.69
Устанавливается соединение с pypi.python.org|140.211.10.69|:80... соединение установлено.
Запрос HTTP послан, ожидается ответ... 200 OK
Длина: 247594 (242K) [application/octet-stream]
Сохраняется в каталог: `pip-1.3.1.tar.gz'.

100%[==============================================================================>] 247 594      306K/s   в 0,8s

2013-05-06 00:18:07 (306 KB/s) - `pip-1.3.1.tar.gz' сохранён [247594/247594]

c:\projects>

tar  xzf  pip-1.3.1.tar.gz
cd  pip-1.3.1
python  setup.py  install



Distribute - это замена  Setuptools
PIP - это замена easy_install




модуль subprocess


Начиная с версии 2.4 библиотека Python включает в себя модуль subprocess.

Это универсальное средство для:

- запуска новых процессов
- подключения к их потокам (stdin, stdout, stderr)
- получения возвращаемого кода по завершению

Класс Popen() вызывает процесс и возвращает управление программе не ожидая его завершения.

Класс subprocess.Popen

subprocess.Popen(
args,
bufsize=-1,
executable=None,
stdin=None,
stdout=None,
stderr=None,
preexec_fn=None,
close_fds=True,
shell=False,
cwd=None,
env=None,
universal_newlines=False,
startupinfo=None,
creationflags=0,
restore_signals=True,
start_new_session=False,
pass_fds=(),
*,
encoding=None,
errors=None,
text=None
)


Примеры:

subprocess.Popen('C:\\Windows\\System32\\calc.exe')

Передача аргументов в командную строку.

Мы можем передать командной строке аргументы при создании объекта Popen.
Для этого мы передаем список в аргумент Popen, содержащий имя программы и аргументы к ее запуску.

subprocess.Popen(['notepad', 'C:\\file.txt'])
subprocess.Popen(['ping', 'oracle.com'])


Если аргументу shell присвоить значение True, то команда будет выполнена через оболочку.
Эта опция наиболее характерна для Windows.
Для Windows класс Popen использует CreateProcess() для выполнения дочерней программы,
который предполагает что args - это строка.
Если args - список, то он будет преобразован в строку используя метод list2cmdline().

Если мы хотим выполнить встроенную команду оболочки Windows (например, dir или copy),
то необходимо указать shell=True
Для запуска командного файла или исполняемого файла на основе консоли shell=True указывать не нужно.
В Windows при shell=True переменная среды COMSPEC указывает оболочку по умолчанию.

subprocess.Popen(['start', 'C:\\file.txt'], shell=True)

subprocess.Popen(['dir'], shell=True)



Для Unix так:

Класс Popen использует os.execvp(), чтобы выполнить дочернюю программу.

subprocess.Popen(['ls -l'], shell=True)

Однако, эта же команда работает и без указания shell.
В случае  shell=True, необходимая команда задаётся целиком одной строкой.
А в случае  shell=False (по умолчанию), команда может задаваться в виде списка.

subprocess.Popen(['ls', '-l'], shell=False)

subprocess.Popen(['/bin/sh', '-c', args[0], args[1], ...])


Также Popen поддерживает менеджеры контекста:

with Popen(["ifconfig"], stdout=PIPE) as proc:
    log.write(proc.stdout.read())



>>> from subprocess import Popen,PIPE
>>> print Popen("echo Hello World", stdout=PIPE, shell=True).stdout.read()
Hello World

>>>


>>> from subprocess import Popen,PIPE
>>> ipaddress="10.0.2.15"
>>> p = Popen("/usr/sbin/ping -c 5 %s" % ipaddress, shell=True, stdout=PIPE)
>>> out = p.stdout.read()
>>> print out
10.0.2.15 is alive

>>> result = out.split()
>>> print result
['10.0.2.15', 'is', 'alive']





Комментариев нет:

Отправить комментарий