Category: Python module

Solve EnvironmentError: mysql_config not found Mysql-Python pip on Ubuntu

Solve EnvironmentError: mysql_config not found Mysql-Python pip on Ubuntu

If you installing MySQL-python from pip in Ubuntu and see this error : 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879Downloading/unpacking MySQL-python==1.2.3 (from -r requirements.txt (line 3))   Downloading MySQL-python-1.2.3.tar.gz (70Kb): 70Kb downloaded   Running setup.py egg_info for package MySQL-python     sh: mysql_config: not found     Traceback (most recent call last):       File "<string>", line 14, in <module> …

+ Read More

Python Requests Module get Json content into dictionaries

Python Requests Module get Json content into dictionaries

Requests Module is great python module to use urllib2 in easy ways. For instance, let we get some JSON from my Gravatar : 1https://es.gravatar.com/bashlook.json In case you need how to get JSON value using urllib2 : 1234567891011import urllib2 import json uri = "https://es.gravatar.com/bashlook.json" opener = urllib2.urlopen(uri) try:     result = json.load(opener) except ValueError, e: …

+ Read More

Max retries exceeded for url: in Requests Module Python Solved!

Max retries exceeded for url: in Requests Module Python Solved!

Updated! Thanks to @_palsu which give me the right way of proxy usage in urllib : 1result = requests.get(url, proxies={‘http’: ‘http://33.33.33.11:8118’}) Requests module help me much in creating crawlers. But somehow it throw me an error : 1Max retries exceeded for url: …. After a few minutes debugging, I know the problem coming from invalid …

+ Read More

How to sort dictionary by keys or by values in Python

How to sort dictionary by keys or by values in Python

Usually dictionary have sorted by keys. But sometimes it got messy un-sorted dictionary because using dict.update() or while adding new dict. You can sort it by keys using : 12sort_dict = [x for x in messy_dict.iteritems()] sort_dict.sort(key=lambda x: x[0]) # sort by key Neat Way by Mr. Kholid : by key: 1sorted(a.items()) by value: 1sorted(a.items(), …

+ Read More

Install python PIL ( Python image Library ) on Ubuntu 11.10 Oneiric

Install python PIL ( Python image Library ) on Ubuntu 11.10 Oneiric

Installing PIL in Ubuntu 11.10 Oneiric 64-bit using pip raise problem on JPEG, Zlib or freetype support. First, you need to uninstall PIL by : 1sudo pip uninstall PIL Then you should install default Ubuntu packages : 1sudo apt-get install libjpeg8 libjpeg62-dev libfreetype6 libfreetype6-dev We should fix PIL path libraries by : 123sudo ln -s …

+ Read More