python

$ python --version
Python 2.7.5+
UnicodeEncodeErrorが発生した場合は、sitecustomize.pyでデフォルトのエンコーディングを指定する。

/usr/lib/python2.7/sitecustomize.py

import sys
reload(sys)
sys.setdefaultencoding("utf-8")
Installer

ii  python3-pip   1.5.6-5ubuntu2    all  alternative Python package installer - Python 3 version of the package

Python3 をデフォルトにする

sudo apt install python-is-python3
Arch Linux
# pacman -S python-pip

# pip install pymssql


モジュールの場所を調べる
$ python3
Python 3.4.3 (default, Mar 26 2015, 22:03:40) 
[GCC 4.9.2] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pymssql
>>> type (pymssql)
<class 'module'>
>>> print (pymssql.__file__)
/home/uchida/.local/lib/python3.4/site-packages/pymssql.cpython-34m.so
>>> quit ()
モジュールのバージョンを調べる
$ python
Python 3.6.2 (default, Jul 20 2017, 03:52:27) 
[GCC 7.1.1 20170630] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import requests
>>> requests.__version__
'2.18.3'
>>> quit()
Ubuntu
$ python3
Python 3.4.3+ (default, Oct 14 2015, 16:03:50) 
[GCC 5.2.1 20151010] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> print (sys.path)
['', '/usr/lib/python3.4', '/usr/lib/python3.4/plat-x86_64-linux-gnu', '/usr/lib/python3.4/lib-dynload', '/usr/local/lib/python3.4/dist-packages', '/usr/lib/python3/dist-packages']
>>> 
エラー

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

json_str.encode('utf-8')
result_aa

outarea_aa
outarea_bb
outarea_cc
outarea_dd
outarea_ee
outarea_ff
outarea_gg
outarea_hh

Return

May/09/2023 AM 08:15