Python

From Indie IT Wiki

Fix: ERROR: Cache entry deserialization failed, entry ignored

rm -rfv ~/.cache/pip

Fix: ERROR: import httplib ImportError: No module named httplib

sudo apt-get -y install libpython2.7-stdlib

HOWTO: List All Outdate Python Packages Using PIP

sudo -i
pip list --outdated --format=freeze

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

FIX: ERROR: NO_PUBKEY 5BB92C09DB82666C

sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 5BB92C09DB82666C
sudo apt update

HOWTO: Upgrade Python 3.5 On Ubuntu 16.04 LTS

This will upgrade the version of Python 3.5 which is fixed with the standard repositories to the latest 3.6 release.

3.5.2 --> 3.6.10

Do NOT uninstall python 3.5 under any circumstances!

sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt-get update
sudo apt-get install --yes python3.6

HOWTO: Upgrade To Python 3.5 On Ubuntu 14.04 LTS

sudo add-apt-repository --yes ppa:fkrull/deadsnakes
sudo apt-get update
sudo apt-get install --yes python3.5 python3.5-dev
wget -q -O - https://bootstrap.pypa.io/pip/3.5/get-pip.py | sudo python3.5

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

Install PIP

sudo -i
wget https://bootstrap.pypa.io/get-pip.py
python get-pip.py

HOWTO: Install PIP

Ubuntu 14.04

sudo apt-get -y install python-pip

HOWTO: Use PIP

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

HOWTO: Fix: ImportError: cannot import name 'sysconfig'

sudo apt-get install python3-distutils

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

HOWTO: List Package Versions Available

pip install MySQL_python==