15
15

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

sitecustomize.py を使わず usercustomize.py を使おうね

Last updated at Posted at 2013-11-27

sitecustomize.pyを置く前にusercustomize.pyを置いてみてはいかがでしょうか。

配置場所

>>> import site
>>> userdir = site.getusersitepackages()

実体

windows
>>> userdir()
'C:\\Users\\owner\\AppData\\Roaming\\Python\\Python27\\site-packages'
ubuntu
>>> userdir()
'/home/owner/.local/lib/python2.7/site-packages'
mac
>>> userdir()
'/Users/owner/Library/Python/2.7/lib/python/site-packages'

ディレクトリを作る

windows
>>> os.makedirs(userdir)
>>> os.system('explorer.exe %s' % userdir)
1

usercustomize.pyを作成

windows
>>> f = open("%s\\usercustomize.py" % userdir,"w")
>>> str="""import sys
... sys.setdefaultencoding('utf-8')
... """
>>> f.write(str)
>>> f.close()

usercustomize.pyの処理が適用されたか確認

>>> import sys
>>> sys.getdefaultencoding()
'utf-8'

失敗していればasciiが表示される。

15
15
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
15
15

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?