Python

From Indie IT Wiki
Jump to: navigation, search

HOWTO: Upgrade All Python Packages Using PIP

This is an unofficial method, but works very well. It can take a LONG time so please be patient.

sudo -i
pip freeze --local | grep -v '^\-e' | cut -d = -f 1  | xargs -n1 pip install -U

HOWTO: Upgrade Python 2.7 On Ubuntu 14.04 LTS

This will upgrade the version of Python 2.7 which is fixed with the standard repositories to the last 2.7 release.

2.7.5 --> 2.7.12

This will fix a lot of security issues and SSL errors.

sudo add-apt-repository ppa:fkrull/deadsnakes-python2.7
sudo apt-get update
sudo apt-get check
sudo apt-get --download-only dist-upgrade
sudo apt-get --simulate dist-upgrade
sudo apt-get --quiet dist-upgrade
which python
python --version

HOWTO: Upgrade Python 2.7 On Ubuntu 12.04 LTS

This will upgrade the version of Python 2.7 which is fixed with the standard repositories to the last 2.7 release.

2.7.4 --> 2.7.10

sudo apt-add-repository ppa:fkrull/deadsnakes-python2.7
sudo aptitude update
sudo aptitude -y safe-upgrade
sudo reboot
sudo python --version

https://www.python.org/downloads

HOWTO: List Installed Python Packages

sudo pip list

HOWTO: Use PIP

https://pypi.python.org/pypi/pip

HOWTO: Fix: request disallowed by robots.txt

mechanize._response.httperror_seek_wrapper: HTTP Error 403: request disallowed by robots.txt

Add the following (in bold) under the first Browser line in your script...

br=mechanize.Browser()
br.set_handle_robots(False)

Thanks - http://stackoverflow.com/questions/2846105/screen-scraping-getting-around-http-error-403-request-disallowed-by-robots-tx

HOWTO: Fix: ImportError: cannot import name IncompleteRead

 sudo easy_install requests==2.3.0

HOWTO: Install A Python Module Manually

Download the module and untar it, then run the setup.py file...

wget http://terminal-py.googlecode.com/files/terminal-py-0.1.1.tar.gz
tar -xzvf terminal-py-0.1.1.tar.gz
cd terminal-py-0.1.1
sudo python setup.py install

HOWTO: Modules List

https://pypi.python.org/pypi