https://wiki.archlinux.org/api.php?action=feedcontributions&user=Lucas.simon994&feedformat=atomArchWiki - User contributions [en]2024-03-28T13:30:43ZUser contributionsMediaWiki 1.41.0https://wiki.archlinux.org/index.php?title=Python&diff=250582Python2013-03-14T06:19:28Z<p>Lucas.simon994: edited errors in commands and added extra info</p>
<hr />
<div>[[Category:Programming language]]<br />
[[de:Python]]<br />
[[zh-CN:Python]]<br />
{{Article summary start}}<br />
{{Article summary text|This article explains how to install and configure Python.}}<br />
{{Article summary heading|Related}}<br />
{{Article summary wiki|Python Package Guidelines}}<br />
{{Article summary wiki|mod_python}}<br />
{{Article summary wiki|Python VirtualEnv}}<br />
{{Article summary end}}<br />
<br />
[http://www.python.org Python] "is a remarkably powerful dynamic programming language that is used in a wide variety of application domains. Python is often compared to Tcl, Perl, Ruby, Scheme or Java."<br />
<br />
==Installation==<br />
<br />
There are currently two versions of Python: Python 3 (which is the default) and the older Python 2.<br />
<br />
===Python 3===<br />
<br />
Python 3 is the latest version of the language, and is '''incompatible with Python 2'''. The language is mostly the same, but many details, especially how built-in objects like dictionaries and strings work, have changed considerably, and a lot of deprecated features have finally been removed. Also, the standard library has been reorganized in a few prominent places. For an overview of the differences, visit [http://wiki.python.org/moin/Python2orPython3 Python2orPython3] and their relevant [http://diveintopython3.ep.io/porting-code-to-python-3-with-2to3.html chapter] in Dive into Python 3.<br />
<br />
To install the latest version of Python 3, [[pacman|install]] the {{Pkg|python}} package from the [[Official Repositories|official repositories]].<br />
<br />
If you would like to build the latest RC/betas from source, visit [http://www.python.org/download/ Python Downloads]. The [[Arch User Repository]] also contains good [[PKGBUILD]]s. If you do decide to build the RC, note that the binary (by default) installs to {{ic|/usr/local/bin/python3.x}}.<br />
<br />
===Python 2===<br />
To install the latest version of Python 2, [[pacman|install]] the {{Pkg|python2}} package from the [[Official Repositories|official repositories]].<br />
<br />
Python 2 will happily run alongside Python 3. You need to specify '''python2''' in order to run this version.<br />
<br />
Any program requiring Python 2 needs to point to {{ic|/usr/bin/python2}}, instead of {{ic|/usr/bin/python}}.<br />
<br />
To do so, open the program or script in a text editor and change the first line.<br />
<br />
The line will show one of the following:<br />
#!/usr/bin/env python<br />
or<br />
#!/usr/bin/python<br />
<br />
In both cases, just change {{ic|python}} to {{ic|python2}} and the program will then use Python 2 instead of Python 3.<br />
<br />
Another way to force the use of python2 without altering the scripts is to call it explicitely with python2, i.e.<br />
{{bc|python2 myScript.py}}<br />
<br />
Finally, you may not be able to control the script calls, but there is a way to trick the environment. It only works if the scripts use {{ic|#!/usr/bin/env python}}, it won't work with {{ic|#!/usr/bin/python}}. This trick relies on {{ic|env}} searching for the first corresponding entry in the PATH variable.<br />
First create a dummy folder.<br />
$ mkdir ~/bin<br />
Then add a symlink 'python' to python2 in it.<br />
$ ln -s /usr/bin/python2 ~/bin/python<br />
Finally put the new folder ''at the beginning'' of your PATH variable.<br />
$ export PATH=~/bin:$PATH<br />
Note that this change is not permanent and is only active in the current terminal session.<br />
To check which python interpreter is being used by {{ic|env}}, use the following command:<br />
$ which python<br />
<br />
==A permanent approach to switching to Python 2.x==<br />
Instead of changing the local user environment to python 2.x, the default python version for the system can be set. First type into your console<br />
$ cd /usr/bin<br />
and then type in the command <br />
$ ln -l python<br />
which should something like<br />
$ lrwxrwxrwx 1 root root 7 Dec 22 13:23 python -> python3<br />
If you receive some kind of error, then python3 is most likely not installed. In that case just install python2 by issuing the command<br />
$ sudo pacman -S python2<br />
To make this the default, if you are not in root, enter the command<br />
$ sudo ln -sf python2 python<br />
which switches your default version of python to python 2.x. To ensure that you are now using the correct version, type in the comman<br />
$ ln -l python<br />
which will return a value that looks like<br />
$ lrwxrwxrwx 1 root root 7 Mar 13 22:23 python -> python2<br />
<br />
<br />
==Dealing with version problem in build scripts==<br />
Many projects' build scripts assume {{ic|python}} to be Python 2, and that would eventually result in an error - typically complaining that {{ic|print 'foo'}} is invalid syntax. Luckily, many of them call {{ic|python}} in the {{ic|$PATH}} instead of hardcoding {{ic|#!/usr/bin/python}} in the shebang line, and the Python scripts are all contained within the project tree. So, instead of modifying the build scripts manually, there is an easy workaround. Just create {{ic|/usr/local/bin/python}} with content like this:<br />
<br />
{{hc|/usr/local/bin/python|<nowiki><br />
#!/bin/bash<br />
script=`readlink -f -- "$1"`<br />
case "$script" in<br />
/path/to/project1/*|/path/to/project2/*|/path/to/project3*)<br />
exec python2 "$@"<br />
;;<br />
esac<br />
<br />
exec python3 "$@"<br />
</nowiki><br />
}}<br />
<br />
Where {{ic|<nowiki>/path/to/project1/*|/path/to/project2/*|/path/to/project3*</nowiki>}} is a list of patterns separated by {{ic|<nowiki>|</nowiki>}} matching all project trees.<br />
<br />
Don't forget to make it executable:<br />
<br />
# chmod +x /usr/local/bin/python<br />
<br />
Afterwards scripts within the specified project trees will be run with Python 2.<br />
<br />
==Integrated Development Environments==<br />
There are some IDEs for Python available in the [[Official Repositories|official repositories]].<br />
<br />
===Eclipse===<br />
<br />
Eclipse supports both Python 2.x and 3.x series by using the [[Eclipse#PyDev|PyDev]] extension.<br />
<br />
===Eric===<br />
For the latest Python 3 compatible version, [[pacman|install]] the {{Pkg|eric}} package.<br />
<br />
Version 4 of Eric is Python 2 compatible and can be installed with the {{Pkg|eric4}} package.<br />
<br />
These IDEs can also handle [[Ruby]].<br />
<br />
===Ninja===<br />
<br />
The Ninja IDE is provided by the package {{Pkg|ninja-ide}}.<br />
<br />
===Spyder===<br />
<br />
Spyder (previously known as Pydee) is a powerful interactive development environment for the Python language with advanced editing, interactive testing, debugging and introspection features. It focuses on scientific computations, providing a matlab-like environment. It can be installed with the package {{AUR|spyder}}<br />
<br />
== Getting easy_install ==<br />
<br />
The easy_install tool is available in the package {{Pkg|python-distribute}} or {{Pkg|python2-distribute}}.<br />
<br />
==Widget bindings ==<br />
The following [[wikipedia:widget toolkit|widget toolkit]] bindings are available:<br />
*{{App|[[TkInter]]|[[Tk]] bindings|http://wiki.python.org/moin/TkInter|standard module}}<br />
*{{App|[[pyQt]]|[[Qt]] bindings|http://www.riverbankcomputing.co.uk/software/pyqt/intro|{{Pkg|pyqt}}}}<br />
*{{App|[[pySide]]|[[Qt]] bindings|http://www.pyside.org/|{{Pkg|python2-pyside}}}}<br />
*{{App|[[pyGTK]]|[[GTK+]] bindings|http://www.pygtk.org/|{{Pkg|pygtk}}}}<br />
*{{App|[[wxPython]]|[[wxWidgets]] bindings|http://wxpython.org/|{{Pkg|wxpython}}}}<br />
To use these with Python, you may need to install the associated widget kits.<br />
<br />
==Old versions==<br />
Old versions of Python are available via the [[Arch User Repository|AUR]] and may be useful for historical curiosity, old applications that don't run on current versions, or for testing Python programs intended to run on a distribution that comes with an older version (eg, RHEL 5.x has Python 2.4, or Ubuntu 12.04 has Python 3.1):<br />
*{{AUR|python15}}: Python 1.5.2<br />
*{{AUR|python16}}: Python 1.6.1<br />
*{{AUR|python24}}: Python 2.4.6<br />
*{{AUR|python25}}: Python 2.5.6<br />
*{{AUR|python26}}: Python 2.6.8<br />
*{{AUR|python30}}: Python 3.0.1<br />
*{{AUR|python31}}: Python 3.1.5<br />
*{{AUR|python32}}: Python 3.2.3<br />
<br />
As of November 2012, Python upstream only supports Python 2.6, 2.7, 3.1, 3.2, and 3.3 for security fixes. Using older versions for Internet-facing applications or untrusted code may be dangerous and is not recommended.<br />
<br />
Extra modules/libraries for old versions of Python may be found on the AUR by searching for python(version without decimal), eg searching for "python26" for 2.6 modules.<br />
<br />
==More Resources==<br />
* [http://shop.oreilly.com/product/9780596158071.do Learning Python] is one of the most comprehensive, up to date, and well-written books on Python available today.<br />
* [http://www.diveintopython.net/ Dive Into Python] is an excellent (free) resource, but perhaps for more advanced readers and [http://diveintopython3.ep.io/ has been updated for Python 3].<br />
* [http://www.swaroopch.com/notes/Python A Byte of Python] is a book suitable for users new to Python (and scripting in general).<br />
* [http://learnpythonthehardway.org Learn Python The Hard Way] the best intro to programming.<br />
* [http://facts.learnpython.org facts.learnpython.org] nice site to learn python.<br />
* [http://stephensugden.com/crash_into_python/ Crash into Python] Also known as ''Python for Programmers with 3 Hours'', this guide gives experienced developers from other languages a crash course on Python.<br />
* [http://www.apress.com/book/view/9781590598726 Beginning Game Development with Python and Pygame: From Novice to Professional] for games<br />
<br />
==For Fun==<br />
Try the following snippets from Python's interactive shell:<br />
<br />
>>> import this<br />
<br />
>>> from __future__ import braces<br />
<br />
>>> import antigravity</div>Lucas.simon994https://wiki.archlinux.org/index.php?title=Python&diff=250574Python2013-03-14T04:34:48Z<p>Lucas.simon994: formatted code</p>
<hr />
<div>[[Category:Programming language]]<br />
[[de:Python]]<br />
[[zh-CN:Python]]<br />
{{Article summary start}}<br />
{{Article summary text|This article explains how to install and configure Python.}}<br />
{{Article summary heading|Related}}<br />
{{Article summary wiki|Python Package Guidelines}}<br />
{{Article summary wiki|mod_python}}<br />
{{Article summary wiki|Python VirtualEnv}}<br />
{{Article summary end}}<br />
<br />
[http://www.python.org Python] "is a remarkably powerful dynamic programming language that is used in a wide variety of application domains. Python is often compared to Tcl, Perl, Ruby, Scheme or Java."<br />
<br />
==Installation==<br />
<br />
There are currently two versions of Python: Python 3 (which is the default) and the older Python 2.<br />
<br />
===Python 3===<br />
<br />
Python 3 is the latest version of the language, and is '''incompatible with Python 2'''. The language is mostly the same, but many details, especially how built-in objects like dictionaries and strings work, have changed considerably, and a lot of deprecated features have finally been removed. Also, the standard library has been reorganized in a few prominent places. For an overview of the differences, visit [http://wiki.python.org/moin/Python2orPython3 Python2orPython3] and their relevant [http://diveintopython3.ep.io/porting-code-to-python-3-with-2to3.html chapter] in Dive into Python 3.<br />
<br />
To install the latest version of Python 3, [[pacman|install]] the {{Pkg|python}} package from the [[Official Repositories|official repositories]].<br />
<br />
If you would like to build the latest RC/betas from source, visit [http://www.python.org/download/ Python Downloads]. The [[Arch User Repository]] also contains good [[PKGBUILD]]s. If you do decide to build the RC, note that the binary (by default) installs to {{ic|/usr/local/bin/python3.x}}.<br />
<br />
===Python 2===<br />
To install the latest version of Python 2, [[pacman|install]] the {{Pkg|python2}} package from the [[Official Repositories|official repositories]].<br />
<br />
Python 2 will happily run alongside Python 3. You need to specify '''python2''' in order to run this version.<br />
<br />
Any program requiring Python 2 needs to point to {{ic|/usr/bin/python2}}, instead of {{ic|/usr/bin/python}}.<br />
<br />
To do so, open the program or script in a text editor and change the first line.<br />
<br />
The line will show one of the following:<br />
#!/usr/bin/env python<br />
or<br />
#!/usr/bin/python<br />
<br />
In both cases, just change {{ic|python}} to {{ic|python2}} and the program will then use Python 2 instead of Python 3.<br />
<br />
Another way to force the use of python2 without altering the scripts is to call it explicitely with python2, i.e.<br />
{{bc|python2 myScript.py}}<br />
<br />
Finally, you may not be able to control the script calls, but there is a way to trick the environment. It only works if the scripts use {{ic|#!/usr/bin/env python}}, it won't work with {{ic|#!/usr/bin/python}}. This trick relies on {{ic|env}} searching for the first corresponding entry in the PATH variable.<br />
First create a dummy folder.<br />
$ mkdir ~/bin<br />
Then add a symlink 'python' to python2 in it.<br />
$ ln -s /usr/bin/python2 ~/bin/python<br />
Finally put the new folder ''at the beginning'' of your PATH variable.<br />
$ export PATH=~/bin:$PATH<br />
Note that this change is not permanent and is only active in the current terminal session.<br />
To check which python interpreter is being used by {{ic|env}}, use the following command:<br />
$ which python<br />
<br />
==A permanent approach to switching to Python 2.x==<br />
Instead of changing the local user environment to python 2.x, the default python version for the system can be set. First type into your console<br />
$ cd /usr/bin<br />
and then type in the command <br />
$ ln -l python<br />
which should something like<br />
$ lrwxrwxrwx 1 root root 7 Dec 22 13:23 python -> python3<br />
To make it the default python2, if you are not in root, enter the command<br />
sudo ln -sf python2 python<br />
which switches your default version of python to python 2.x. To ensure that you are now using the correct version, type in the comman<br />
$ ln -l python<br />
which will return a value that looks like<br />
$ lrwxrwxrwx 1 root root 7 Mar 13 22:23 python -> python2<br />
<br />
<br />
==Dealing with version problem in build scripts==<br />
Many projects' build scripts assume {{ic|python}} to be Python 2, and that would eventually result in an error - typically complaining that {{ic|print 'foo'}} is invalid syntax. Luckily, many of them call {{ic|python}} in the {{ic|$PATH}} instead of hardcoding {{ic|#!/usr/bin/python}} in the shebang line, and the Python scripts are all contained within the project tree. So, instead of modifying the build scripts manually, there is an easy workaround. Just create {{ic|/usr/local/bin/python}} with content like this:<br />
<br />
{{hc|/usr/local/bin/python|<nowiki><br />
#!/bin/bash<br />
script=`readlink -f -- "$1"`<br />
case "$script" in<br />
/path/to/project1/*|/path/to/project2/*|/path/to/project3*)<br />
exec python2 "$@"<br />
;;<br />
esac<br />
<br />
exec python3 "$@"<br />
</nowiki><br />
}}<br />
<br />
Where {{ic|<nowiki>/path/to/project1/*|/path/to/project2/*|/path/to/project3*</nowiki>}} is a list of patterns separated by {{ic|<nowiki>|</nowiki>}} matching all project trees.<br />
<br />
Don't forget to make it executable:<br />
<br />
# chmod +x /usr/local/bin/python<br />
<br />
Afterwards scripts within the specified project trees will be run with Python 2.<br />
<br />
==Integrated Development Environments==<br />
There are some IDEs for Python available in the [[Official Repositories|official repositories]].<br />
<br />
===Eclipse===<br />
<br />
Eclipse supports both Python 2.x and 3.x series by using the [[Eclipse#PyDev|PyDev]] extension.<br />
<br />
===Eric===<br />
For the latest Python 3 compatible version, [[pacman|install]] the {{Pkg|eric}} package.<br />
<br />
Version 4 of Eric is Python 2 compatible and can be installed with the {{Pkg|eric4}} package.<br />
<br />
These IDEs can also handle [[Ruby]].<br />
<br />
===Ninja===<br />
<br />
The Ninja IDE is provided by the package {{Pkg|ninja-ide}}.<br />
<br />
===Spyder===<br />
<br />
Spyder (previously known as Pydee) is a powerful interactive development environment for the Python language with advanced editing, interactive testing, debugging and introspection features. It focuses on scientific computations, providing a matlab-like environment. It can be installed with the package {{AUR|spyder}}<br />
<br />
== Getting easy_install ==<br />
<br />
The easy_install tool is available in the package {{Pkg|python-distribute}} or {{Pkg|python2-distribute}}.<br />
<br />
==Widget bindings ==<br />
The following [[wikipedia:widget toolkit|widget toolkit]] bindings are available:<br />
*{{App|[[TkInter]]|[[Tk]] bindings|http://wiki.python.org/moin/TkInter|standard module}}<br />
*{{App|[[pyQt]]|[[Qt]] bindings|http://www.riverbankcomputing.co.uk/software/pyqt/intro|{{Pkg|pyqt}}}}<br />
*{{App|[[pySide]]|[[Qt]] bindings|http://www.pyside.org/|{{Pkg|python2-pyside}}}}<br />
*{{App|[[pyGTK]]|[[GTK+]] bindings|http://www.pygtk.org/|{{Pkg|pygtk}}}}<br />
*{{App|[[wxPython]]|[[wxWidgets]] bindings|http://wxpython.org/|{{Pkg|wxpython}}}}<br />
To use these with Python, you may need to install the associated widget kits.<br />
<br />
==Old versions==<br />
Old versions of Python are available via the [[Arch User Repository|AUR]] and may be useful for historical curiosity, old applications that don't run on current versions, or for testing Python programs intended to run on a distribution that comes with an older version (eg, RHEL 5.x has Python 2.4, or Ubuntu 12.04 has Python 3.1):<br />
*{{AUR|python15}}: Python 1.5.2<br />
*{{AUR|python16}}: Python 1.6.1<br />
*{{AUR|python24}}: Python 2.4.6<br />
*{{AUR|python25}}: Python 2.5.6<br />
*{{AUR|python26}}: Python 2.6.8<br />
*{{AUR|python30}}: Python 3.0.1<br />
*{{AUR|python31}}: Python 3.1.5<br />
*{{AUR|python32}}: Python 3.2.3<br />
<br />
As of November 2012, Python upstream only supports Python 2.6, 2.7, 3.1, 3.2, and 3.3 for security fixes. Using older versions for Internet-facing applications or untrusted code may be dangerous and is not recommended.<br />
<br />
Extra modules/libraries for old versions of Python may be found on the AUR by searching for python(version without decimal), eg searching for "python26" for 2.6 modules.<br />
<br />
==More Resources==<br />
* [http://shop.oreilly.com/product/9780596158071.do Learning Python] is one of the most comprehensive, up to date, and well-written books on Python available today.<br />
* [http://www.diveintopython.net/ Dive Into Python] is an excellent (free) resource, but perhaps for more advanced readers and [http://diveintopython3.ep.io/ has been updated for Python 3].<br />
* [http://www.swaroopch.com/notes/Python A Byte of Python] is a book suitable for users new to Python (and scripting in general).<br />
* [http://learnpythonthehardway.org Learn Python The Hard Way] the best intro to programming.<br />
* [http://facts.learnpython.org facts.learnpython.org] nice site to learn python.<br />
* [http://stephensugden.com/crash_into_python/ Crash into Python] Also known as ''Python for Programmers with 3 Hours'', this guide gives experienced developers from other languages a crash course on Python.<br />
* [http://www.apress.com/book/view/9781590598726 Beginning Game Development with Python and Pygame: From Novice to Professional] for games<br />
<br />
==For Fun==<br />
Try the following snippets from Python's interactive shell:<br />
<br />
>>> import this<br />
<br />
>>> from __future__ import braces<br />
<br />
>>> import antigravity</div>Lucas.simon994https://wiki.archlinux.org/index.php?title=Python&diff=250573Python2013-03-14T04:33:44Z<p>Lucas.simon994: Added in a section to change the default python version</p>
<hr />
<div>[[Category:Programming language]]<br />
[[de:Python]]<br />
[[zh-CN:Python]]<br />
{{Article summary start}}<br />
{{Article summary text|This article explains how to install and configure Python.}}<br />
{{Article summary heading|Related}}<br />
{{Article summary wiki|Python Package Guidelines}}<br />
{{Article summary wiki|mod_python}}<br />
{{Article summary wiki|Python VirtualEnv}}<br />
{{Article summary end}}<br />
<br />
[http://www.python.org Python] "is a remarkably powerful dynamic programming language that is used in a wide variety of application domains. Python is often compared to Tcl, Perl, Ruby, Scheme or Java."<br />
<br />
==Installation==<br />
<br />
There are currently two versions of Python: Python 3 (which is the default) and the older Python 2.<br />
<br />
===Python 3===<br />
<br />
Python 3 is the latest version of the language, and is '''incompatible with Python 2'''. The language is mostly the same, but many details, especially how built-in objects like dictionaries and strings work, have changed considerably, and a lot of deprecated features have finally been removed. Also, the standard library has been reorganized in a few prominent places. For an overview of the differences, visit [http://wiki.python.org/moin/Python2orPython3 Python2orPython3] and their relevant [http://diveintopython3.ep.io/porting-code-to-python-3-with-2to3.html chapter] in Dive into Python 3.<br />
<br />
To install the latest version of Python 3, [[pacman|install]] the {{Pkg|python}} package from the [[Official Repositories|official repositories]].<br />
<br />
If you would like to build the latest RC/betas from source, visit [http://www.python.org/download/ Python Downloads]. The [[Arch User Repository]] also contains good [[PKGBUILD]]s. If you do decide to build the RC, note that the binary (by default) installs to {{ic|/usr/local/bin/python3.x}}.<br />
<br />
===Python 2===<br />
To install the latest version of Python 2, [[pacman|install]] the {{Pkg|python2}} package from the [[Official Repositories|official repositories]].<br />
<br />
Python 2 will happily run alongside Python 3. You need to specify '''python2''' in order to run this version.<br />
<br />
Any program requiring Python 2 needs to point to {{ic|/usr/bin/python2}}, instead of {{ic|/usr/bin/python}}.<br />
<br />
To do so, open the program or script in a text editor and change the first line.<br />
<br />
The line will show one of the following:<br />
#!/usr/bin/env python<br />
or<br />
#!/usr/bin/python<br />
<br />
In both cases, just change {{ic|python}} to {{ic|python2}} and the program will then use Python 2 instead of Python 3.<br />
<br />
Another way to force the use of python2 without altering the scripts is to call it explicitely with python2, i.e.<br />
{{bc|python2 myScript.py}}<br />
<br />
Finally, you may not be able to control the script calls, but there is a way to trick the environment. It only works if the scripts use {{ic|#!/usr/bin/env python}}, it won't work with {{ic|#!/usr/bin/python}}. This trick relies on {{ic|env}} searching for the first corresponding entry in the PATH variable.<br />
First create a dummy folder.<br />
$ mkdir ~/bin<br />
Then add a symlink 'python' to python2 in it.<br />
$ ln -s /usr/bin/python2 ~/bin/python<br />
Finally put the new folder ''at the beginning'' of your PATH variable.<br />
$ export PATH=~/bin:$PATH<br />
Note that this change is not permanent and is only active in the current terminal session.<br />
To check which python interpreter is being used by {{ic|env}}, use the following command:<br />
$ which python<br />
<br />
==A permanent approach to switching to Python 2.x==<br />
Instead of changing the local user environment to python 2.x, the default python version for the system can be set. First type into your console<br />
cd /usr/bin<br />
and then type in the command <br />
ln -l python<br />
which should something like<br />
lrwxrwxrwx 1 root root 7 Dec 22 13:23 python -> python3<br />
To make it the default python2, if you are not in root, enter the command<br />
sudo ln -sf python2 python<br />
which switches your default version of python to python 2.x. To ensure that you are now using the correct version, type in the comman<br />
ln -l python<br />
which will return a value that looks like<br />
lrwxrwxrwx 1 root root 7 Mar 13 22:23 python -> python2<br />
<br />
<br />
==Dealing with version problem in build scripts==<br />
Many projects' build scripts assume {{ic|python}} to be Python 2, and that would eventually result in an error - typically complaining that {{ic|print 'foo'}} is invalid syntax. Luckily, many of them call {{ic|python}} in the {{ic|$PATH}} instead of hardcoding {{ic|#!/usr/bin/python}} in the shebang line, and the Python scripts are all contained within the project tree. So, instead of modifying the build scripts manually, there is an easy workaround. Just create {{ic|/usr/local/bin/python}} with content like this:<br />
<br />
{{hc|/usr/local/bin/python|<nowiki><br />
#!/bin/bash<br />
script=`readlink -f -- "$1"`<br />
case "$script" in<br />
/path/to/project1/*|/path/to/project2/*|/path/to/project3*)<br />
exec python2 "$@"<br />
;;<br />
esac<br />
<br />
exec python3 "$@"<br />
</nowiki><br />
}}<br />
<br />
Where {{ic|<nowiki>/path/to/project1/*|/path/to/project2/*|/path/to/project3*</nowiki>}} is a list of patterns separated by {{ic|<nowiki>|</nowiki>}} matching all project trees.<br />
<br />
Don't forget to make it executable:<br />
<br />
# chmod +x /usr/local/bin/python<br />
<br />
Afterwards scripts within the specified project trees will be run with Python 2.<br />
<br />
==Integrated Development Environments==<br />
There are some IDEs for Python available in the [[Official Repositories|official repositories]].<br />
<br />
===Eclipse===<br />
<br />
Eclipse supports both Python 2.x and 3.x series by using the [[Eclipse#PyDev|PyDev]] extension.<br />
<br />
===Eric===<br />
For the latest Python 3 compatible version, [[pacman|install]] the {{Pkg|eric}} package.<br />
<br />
Version 4 of Eric is Python 2 compatible and can be installed with the {{Pkg|eric4}} package.<br />
<br />
These IDEs can also handle [[Ruby]].<br />
<br />
===Ninja===<br />
<br />
The Ninja IDE is provided by the package {{Pkg|ninja-ide}}.<br />
<br />
===Spyder===<br />
<br />
Spyder (previously known as Pydee) is a powerful interactive development environment for the Python language with advanced editing, interactive testing, debugging and introspection features. It focuses on scientific computations, providing a matlab-like environment. It can be installed with the package {{AUR|spyder}}<br />
<br />
== Getting easy_install ==<br />
<br />
The easy_install tool is available in the package {{Pkg|python-distribute}} or {{Pkg|python2-distribute}}.<br />
<br />
==Widget bindings ==<br />
The following [[wikipedia:widget toolkit|widget toolkit]] bindings are available:<br />
*{{App|[[TkInter]]|[[Tk]] bindings|http://wiki.python.org/moin/TkInter|standard module}}<br />
*{{App|[[pyQt]]|[[Qt]] bindings|http://www.riverbankcomputing.co.uk/software/pyqt/intro|{{Pkg|pyqt}}}}<br />
*{{App|[[pySide]]|[[Qt]] bindings|http://www.pyside.org/|{{Pkg|python2-pyside}}}}<br />
*{{App|[[pyGTK]]|[[GTK+]] bindings|http://www.pygtk.org/|{{Pkg|pygtk}}}}<br />
*{{App|[[wxPython]]|[[wxWidgets]] bindings|http://wxpython.org/|{{Pkg|wxpython}}}}<br />
To use these with Python, you may need to install the associated widget kits.<br />
<br />
==Old versions==<br />
Old versions of Python are available via the [[Arch User Repository|AUR]] and may be useful for historical curiosity, old applications that don't run on current versions, or for testing Python programs intended to run on a distribution that comes with an older version (eg, RHEL 5.x has Python 2.4, or Ubuntu 12.04 has Python 3.1):<br />
*{{AUR|python15}}: Python 1.5.2<br />
*{{AUR|python16}}: Python 1.6.1<br />
*{{AUR|python24}}: Python 2.4.6<br />
*{{AUR|python25}}: Python 2.5.6<br />
*{{AUR|python26}}: Python 2.6.8<br />
*{{AUR|python30}}: Python 3.0.1<br />
*{{AUR|python31}}: Python 3.1.5<br />
*{{AUR|python32}}: Python 3.2.3<br />
<br />
As of November 2012, Python upstream only supports Python 2.6, 2.7, 3.1, 3.2, and 3.3 for security fixes. Using older versions for Internet-facing applications or untrusted code may be dangerous and is not recommended.<br />
<br />
Extra modules/libraries for old versions of Python may be found on the AUR by searching for python(version without decimal), eg searching for "python26" for 2.6 modules.<br />
<br />
==More Resources==<br />
* [http://shop.oreilly.com/product/9780596158071.do Learning Python] is one of the most comprehensive, up to date, and well-written books on Python available today.<br />
* [http://www.diveintopython.net/ Dive Into Python] is an excellent (free) resource, but perhaps for more advanced readers and [http://diveintopython3.ep.io/ has been updated for Python 3].<br />
* [http://www.swaroopch.com/notes/Python A Byte of Python] is a book suitable for users new to Python (and scripting in general).<br />
* [http://learnpythonthehardway.org Learn Python The Hard Way] the best intro to programming.<br />
* [http://facts.learnpython.org facts.learnpython.org] nice site to learn python.<br />
* [http://stephensugden.com/crash_into_python/ Crash into Python] Also known as ''Python for Programmers with 3 Hours'', this guide gives experienced developers from other languages a crash course on Python.<br />
* [http://www.apress.com/book/view/9781590598726 Beginning Game Development with Python and Pygame: From Novice to Professional] for games<br />
<br />
==For Fun==<br />
Try the following snippets from Python's interactive shell:<br />
<br />
>>> import this<br />
<br />
>>> from __future__ import braces<br />
<br />
>>> import antigravity</div>Lucas.simon994