Sunday, June 23, 2019

UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-6: ordinal not in range(128)

import sys  reload(sys)  sys.setdefaultencoding('utf8')

and then apply 
text1=text.decode('utf-8')

How to pass text string from php to python

$text="भारतीय भाषा टेक्स्ट टू स्पीच सिंथेसिस सिस्टम";
$p=shell_exec("python lang-detect.py "."\"$text\"");
Kind Regards  /सादर
Pranaw Kumar / प्रणव कुमार
Principal Technical Officer / प्रमुख तकनीकी अधिकारी
C-DAC MUMBAI / सी-डैक, मुंबई
Ph-(+91) (22) 26201604 Ext: 561
Mob: 7303226767

Friday, June 21, 2019

Unable to import package in python calling from php


Disable ENABLE_USER_SITE and then re-install the package, it would be installed in machine level directory, and then it would be accessible via php also (www-data user)

How to disable ENABLE_USER_SITE
open:
/usr/lib/python2.7/site.py

and change ENABLE_USER_SITE = None
to ENABLE_USER_SITE = False

This url is also having good info about package import: