Difference between revisions of "Python"

From TSG Doc
Jump to navigation Jump to search
(36 intermediate revisions by 3 users not shown)
Line 1: Line 1:
 
{{Infobox software
 
{{Infobox software
 
| name                  = Python
 
| name                  = Python
| logo                  = Python-logo-notext.svg
+
| logo                  = Python-logo-generic.svg
| screenshot            = python-logo-master-v3-TM.png
+
| logo size              = 180px
 +
| logo alt              = Python(tm)
 
| caption                =  
 
| caption                =  
 
| developer              =  
 
| developer              =  
Line 18: Line 19:
 
| platform              =  
 
| platform              =  
 
| website                = [http://www.python.org python.org]
 
| website                = [http://www.python.org python.org]
| resources              =  
+
| resources              = {{Infobox tsg
 +
  | child = yes
 +
  | header2 = Workshop
 +
  | data2 = {{bulleted list
 +
      | [[Workshop: Python for behavioural scientists|Python for behavioural scientists]]
 +
  }}
 +
}}
 
    
 
    
 
}}
 
}}
  
[[wikipedia:Python_(programming_language)|Python]] is a general-purpose, high-level programming language. It is also a type of snake, but one is arguably more suitable for behavioral research than the other.
+
[[wikipedia:Python_(programming_language)|Python]] is a general-purpose, high-level programming language. It is also a [[wikipedia:Python_%28genus%29|type of snake]], but one is arguably more relevant to your research than the other.
  
 
<!-- Table of Contents will be generated here -->
 
<!-- Table of Contents will be generated here -->
Line 29: Line 36:
  
 
===Windows (32 bit)===
 
===Windows (32 bit)===
# Download the [https://www.python.org/downloads/ Win32 installer]
+
# Download the '''[https://www.python.org/downloads/ Win32 installer]'''
 
# Double-click on the executable and follow the steps on your screen.
 
# Double-click on the executable and follow the steps on your screen.
  
Line 47: Line 54:
  
 
===Package Management===
 
===Package Management===
After Python is installed, you can use [[wikipedia:Pip_(package_manager)|pip]] to install your required packages. pip is included with Python 2.7.9. For older versions, use the following steps to install:
+
 
 +
==== pip ====
 +
After Python is installed, you can use [[wikipedia:Pip_(package_manager)|pip]] to install your required packages. '''pip is included with Python 2.7.9 or greater'''. For older versions, use the following steps to install:
  
 
# Download [https://raw.github.com/pypa/pip/master/contrib/get-pip.py get-pip.py]
 
# Download [https://raw.github.com/pypa/pip/master/contrib/get-pip.py get-pip.py]
Line 59: Line 68:
 
This location may differ if you have installed Python somewhere else.
 
This location may differ if you have installed Python somewhere else.
  
===List of Site-Packages===
+
==== Setuptools ====
 +
For package management with setuptools, install setuptools using the following command: <code style="background-color:#000; color:#fff; padding:1px 3px;">pip install -U setuptools</code>
 +
 
 +
To install a package, simply execute the following command: <code style="background-color:#000; color:#fff; padding:1px 3px;">c:\easy_install PACKAGE_NAME</code><br/>
 +
Replace PACKAGE_NAME with the name of the package of choice.
  
 +
===List of Python Packages===
 
{| class="wikitable"
 
{| class="wikitable"
 
|-
 
|-
Line 68: Line 82:
 
! Installer Type
 
! Installer Type
 
! URL
 
! URL
 
 
|-
 
|-
 
| PIL || Python Image Library || style="background-color:#9F9;" | Yes || Package Manager || http://www.pythonware.com/products/pil/   
 
| PIL || Python Image Library || style="background-color:#9F9;" | Yes || Package Manager || http://www.pythonware.com/products/pil/   
Line 105: Line 118:
 
|-
 
|-
 
| FreeType || Library to Render Fonts || style="background-color:#9F9;" | Yes  || Manual Install || [[file:freetype.zip]]
 
| FreeType || Library to Render Fonts || style="background-color:#9F9;" | Yes  || Manual Install || [[file:freetype.zip]]
 +
|-
 +
| Psignifit || || || ||
 
|-
 
|-
 
| Psychopy || Psychology Software in Python || style="background-color:#9F9;" | Yes  || Package Manager || http://www.psychopy.org
 
| Psychopy || Psychology Software in Python || style="background-color:#9F9;" | Yes  || Package Manager || http://www.psychopy.org
 
|}
 
|}
  
=== Setup-Tools ===
+
For Psychopy dependancies, check the [[Psychopy]] page.
To install setup-tools, execute the following command in CMD: <code style="background-color:#000; color:#fff; padding:1px 3px;">pip install -U setuptools</code>
 
 
 
  
 
=== Windows Handlers ===
 
=== Windows Handlers ===
Line 155: Line 168:
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==See Also== <!-- Optional -->
+
==See Also==
 
*[[Psychopy]]
 
*[[Psychopy]]
 
+
*[[Workshop: Python for social scientists]]
==References==
+
<!--
<references />  
+
*[[Workshop: Python for behavioural scientists]]
 +
==References==
 +
<references /> -->
  
 
==External Links==  
 
==External Links==  
 
*{{Official website|http://www.python.org}}
 
*{{Official website|http://www.python.org}}

Revision as of 16:13, 23 February 2018

Python
Python(tm)
Installed version2.7.9
Development statusActive
Written inPython
Websitepython.org

Python is a general-purpose, high-level programming language. It is also a type of snake, but one is arguably more relevant to your research than the other.


Installation

Windows (32 bit)

  1. Download the Win32 installer
  2. Double-click on the executable and follow the steps on your screen.

Configuration

Windows Environment Variables

Computer --> Properties --> Advanced settings --> Environment Variables.

Python env.jpg

Add the following Path:

C:\Python27;C:\Python27\Lib\site-packages\;C:\Python27\Scripts\;

Python path.jpg

Python path2.jpg

Package Management

pip

After Python is installed, you can use pip to install your required packages. pip is included with Python 2.7.9 or greater. For older versions, use the following steps to install:

  1. Download get-pip.py
  2. Execute get-pip by entering the following command: python get-pip.py

To install a package, simply execute the following command: c:\pip install PACKAGE_NAME
Replace PACKAGE_NAME with the name of the package of choice.

Note: By default, packages are installed in the following folder (Windows):

C:\Python27\Lib\site-packages

This location may differ if you have installed Python somewhere else.

Setuptools

For package management with setuptools, install setuptools using the following command: pip install -U setuptools

To install a package, simply execute the following command: c:\easy_install PACKAGE_NAME
Replace PACKAGE_NAME with the name of the package of choice.

List of Python Packages

Python Library Description Installed Installer Type URL
PIL Python Image Library Yes Package Manager http://www.pythonware.com/products/pil/
SciPy Python-based ecosystem of open-source software for mathematics, science, and engineering. Yes Package Manager http://www.scipy.org/install.html
PyWin32 Python Extensions for Windows Yes Windows Installer http://sourceforge.net/projects/pywin32/files/pywin32/
PySerial Serial access for Python Yes Windows Installer https://pypi.python.org/pypi/pyserial
wxPython GUI Toolkit for Python Yes Windows Installer http://www.wxpython.org/download.php#msw
matplotlib 2D plotting library for Python Yes Windows Installer http://matplotlib.org/downloads.html
pyo dedicated Python module for digital signal processing Yes Windows Installer http://ajaxsoundstudio.com/software/pyo/
Opencv2 Open Source Computer Vision is a library of programming functions mainly aimed at real-time computer vision Yes Windows Installer http://opencv.org/
PyQt Python binding of the cross-platform GUI toolkit Qt Yes Windows Installer http://www.riverbankcomputing.co.uk/software/pyqt/download5
PyQtGraph Scientific Graphics and GUI Library for Python Yes Windows Installer http://www.pyqtgraph.org/
LXML library for processing XML and HTML in the Python language Yes Package Manager http://lxml.de/
PyGame Pygame is a set of Python modules designed for writing games. Yes Windows installer http://pygame.org/news.html
PANDAS Python Data Analysis Library Yes Package Manager http://pandas.pydata.org/
Expyriment A Python library for congnitive and neuroscientific experiments. Yes Package Manager http://www.expyriment.org/
Pyparse Parse text files in an easier and more maintainable manner Yes Package Manager https://pypi.python.org/pypi/PyParse/1.1.7
AVbin media decoding/decompression library Yes Windows Installer https://code.google.com/p/avbin/
Pyglet a cross-platform windowing and multimedia library for Python. Yes Manual Install File:Pyglet-1.1.4.zip
FreeType Library to Render Fonts Yes Manual Install File:Freetype.zip
Psignifit
Psychopy Psychology Software in Python Yes Package Manager http://www.psychopy.org

For Psychopy dependancies, check the Psychopy page.

Windows Handlers

Check the Handlers by opening the Windows registry editor.

Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\Python.CompiledFile\shell\open\command]
@="\"C:\\Python27\\python.exe\" \"%1\" %*"

Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\Python.File\shell\open\command]
@="\"C:\\Python27\\python.exe\" \"%1\" %*"

Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Python.CompiledFile\shell\open\command]
@="\"C:\\Python27\\python.exe\" \"%1\" %*"

Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Python.File\shell\open\command]
@="\"C:\\Python27\\python.exe\" \"%1\" %*"


Python DLL Files

  • C:\Python27\DLLs\
  • Path Within the script.
  • C:\Windows\System32 or
  • C:\Windows\SysWOW64

Usage

Example: TestArgs.py

Execute the following script within the commandline (CMD): python testArgs.py a.
You should see the following result:

number of argument:  2
 argv[0]: ./testArgs.py
 argv[1]: a

See Also

External Links