Which Version?
What is the difference? Are they backward compatible?
Summary: Python 2.x is legacy, Python 3.x is the present and future of the language (from the PythonWiki). Python3 has been in active development for 5 years. Python3 is not backward compatible with Python2. Many of the current Linux and Mac distributions are still using Python2. Not all libraries have been ported to Python3 yet. Python2 is (still) better documented.
Installing Python on Ubuntu
Both Python2 and Python3 are installed by default on Ubuntu 14.10:
craig@U1454001:~$ whereis python2 python2: /usr/bin/python2.7 /usr/bin/python2 /usr/lib/python2.7 /etc/python2.7 /usr/local/lib/python2.7 /usr/include/python2.7 /usr/share/man/man1/python2.1.gz craig@U1454001:~$ python2 --version Python 2.7.8 craig@U1454001:~$ python --version Python 2.7.8
and python3:
craig@U1454001:~$ whereis python3 python3: /usr/bin/python3.4m /usr/bin/python3 /usr/bin/python3.4 /usr/lib/python3 /usr/lib/python3.4 /etc/python3 /etc/python3.4 /usr/local/lib/python3.4 /usr/share/python3 /usr/share/man/man1/python3.1.gz craig@U1454001:~$ python3 --version Python 3.4.2
Pip Installs Python (pip)
pip is a package management system used to install and manage software packages written in Python.
pip makes installing Python software packages as easy as issuing one command:
pip install some-package-name
Check if pip is already installed by issuing this command:
craig@U1454001:~$ whereis pip pip:
pip is not installed by default on Ubuntu, so likely you'll get an empty output as I did above.
You can correct this by typing:
craig@U1454001:~$ sudo apt-get install build-essential python-dev -y craig@U1454001:~$ sudo apt-get install python-pip -y
build-esssential python-dev is a python development package that provides the necessary header files for your version of Python.
Installing Setuptools
Setuptools is a package development process that enhances the Python standard library distutils (distribution utilities).
Setuptools can be installed by running this command:
craig@U1454001:~$ wget https://bootstrap.pypa.io/ez_setup.py -O - | sudo python creating 'dist/setuptools-12.3-py2.7.egg' and adding 'build/bdist.linux-x86_64/egg' to it removing 'build/bdist.linux-x86_64/egg' (and everything under it) Processing setuptools-12.3-py2.7.egg Copying setuptools-12.3-py2.7.egg to /usr/local/lib/python2.7/dist-packages Adding setuptools 12.3 to easy-install.pth file Installing easy_install script to /usr/local/bin Installing easy_install-2.7 script to /usr/local/bin Installed /usr/local/lib/python2.7/dist-packages/setuptools-12.3-py2.7.egg Processing dependencies for setuptools==12.3 Finished processing dependencies for setuptools==12.3
References
- Resources
- [GitHub] Installation Scripts (based on this article)
- Python
- [PythonWiki] Python2OrPython3
- [Learn to Code With Me] Python2 or Python3
- Troubleshooting
- [AskUbuntu] Fixing the "IncompleteRead" error
No comments:
Post a Comment