Pythonがファイルを開くときなどに使われるエンコーディングはロケール(WindowsではANSIコードページ)依存でした。 Unixの世界ではどんどんUTF-8ロケールが一般的になっている一方、WindowsのANSIコードページはなかなかUTF-8になりません。 そのために、Unixユーザーが open(filepath) のようにエンコーディングを指定しないままUTF-8を仮定するコードを気軽に書いてしまって、Windowsユーザーがエラーで困るといった問題が発生します。 また、Windowsでもメモ帳(Notepad.exe)やVSCodeはすでにUTF-8をデフォルトのエンコーディングで使用しています。ANSIコードページがUTF-8になるのを待っていたらどんどん周りの環境から置いていかれ、レガシー化してしまいます。 Pythonがデフォルトで利用するエンコーディングをWind
Python がテキストファイルを開く時のデフォルトエンコーディングがUTF-8でないことは、多くのWindowsユーザー、特にプログラミング初心者にとって障害になっています。 UnicodeDecodeError で検索すると、多くのWindowsユーザーが問題に遭遇しているのがわかります。 https://qiita.com/Yuu94/items/9ffdfcb2c26d6b33792e https://www.mikan-partners.com/archives/3212 https://teratail.com/questions/268749 https://github.com/neovim/pynvim/issues/443 https://www.coder.work/article/1284080 https://teratail.com/questions/2713
Python やそのパッケージをインストールする方法はいくつかありますが、ここでは Anaconda を使ってインストールする方法を紹介します。 私の周りでは Anaconda で環境構築をすることと Python コミュニティ標準の方法をとることの是非についての議論をよく見かけます。自分の目的にあったものを選択すれば良いと思いますが、初心者にとってどちらが目的に叶うものかを判断するのは難しいことかもしれません。 以下にディストリビューターとして Anaconda (Continuum Analytics 社) が提供している価値について私見をまとめました。 Anaconda は Environment Isolation Tool (環境分離ツール) ではない 一方で Python コミュニティ公式のバイナリーディストリビューションを提供するツールである wheel も充実してきました。
機械学習ブームなどにより、 Python を触り始める Rubyist が増えてきたと思います。その際に問題になりやすいのが環境構築です。Rubyだと rbenv がデファクトスタンダードになっているのに、なぜか Python に… 私の立ち位置もともとは、数年前まで 年に一回Python3でNLTKやらscikit-learnやら機械学習や自然言語処理の環境を作ろうと試みては失敗してPython使うものかと思っていた人でした。それが、Anacondaで環境導入すると、面倒なことは何も考えずに済むということを知り、CookpadではAnacondaを前提に環境構築を勧めていました。 今は、ymotongpooに「郷に入っては郷に従え」と言われたため、pip+virtualenv/venvで全てをこなしていますが、これで困ったことは特にありません。macOS, Windows, Linuxそ
Pythonは、習得が容易で、より大きく複雑なアプリケーションの開発にすぐに適用していけることから、コンピューティング環境に広く普及し、勢いを強めています。ただ、あまりに明瞭で親しみやすい言語なので、ソフトウェアエンジニアやシステムアドミニストレータが警戒を解いてしまい、セキュリティに重大な影響を及ぼすコーディングミスを誘発する可能性はあるかもしれません。主に、初めてPythonを使う人を対象とするこの記事では、この言語のセキュリティ関連のクセに触れます。ベテラン開発者にとってもその特異性を意識するきっかけになればと思います。 入力関数 Python 2に多数存在するビルトイン関数の中で、 input はセキュリティの面で完全に難点です。この関数をひとたび呼び出すと、標準入力から読み込んだものが即座にPythonコードとして評価されます。 $ python2 >>> input() dir
昨日 mysqlclient 1.3.10 をリリースしました。 今までは Windows 版の wheel は Python 2.7 だけに提供していたのですが、 1.3.10 からは 3.5 と 3.6 だけに提供して 2.7 はドロップしました。 そもそも今まで Python 3 に wheel を提供できてなかったのは、 MySQL Connector/C の VC14 (VS2015) に対応したライブラリが提供されておらず、 Python 3.5, 3.6 は VC14 でビルドされていて VC12 用のライブラリにリンクすると大量のエラーでるわ自分で手順読みながら頑張って MySQL をソースからビルドしてもなんか動かないわで諦めてたからです。 それが、2年待て、よーーーやく MySQL Connector/C 6.1.9 から VC14 のライブラリが同梱される用になりまし
pyspaの統合思念体の渋川です。 「pyenv使いましょう!」系の記事、全部ゴミ — Yoshifumi YAMAGUCHI (@ymotongpoo) September 29, 2016 これはpyenvがダメではなくて、pyenvをとりあえずインストールしておきましょう記事がダメという意味だそうです。すでにとんぷーが5年前にこの問題について書いています。これを読んで分かる人には不要です。 この記事では「便利」と「必要」は分けて考えています。後者にフォーカスしています。 前提知識 Environment Isolation Tool(環境分離ツール)というカテゴリの開発補助ツールがあります。pip install Sphinxとか書いたら、ライブラリはグローバル空間に入っちゃいます。複数バージョン入れられません。そんなときに使うのが、この環境分離ツールです。最近はいろいろな言語がこれ
Python comes with batteries included, but console applications have no color. This project brings a very simple interface to colored console output. It does not replace curses or more sophisticated libraries. If you just need to print colored text using the same API on Linux, Windows and Mac OS X, colorconsole can be a good option. It uses ctype… License
4月から都会でOLとして働き始めたので, OL的windowsの事務処理環境を手探りで作ってみました. OLとWindows 事務処理といえばOffice, 当然Windowsで行うことになります. 今時のOLは家ではLinuxを使っているはずなので, 自然とシェル環境で困ることになります. Windowsが本当にわからない linuxコマンド使いたい(DOS音痴) Cygwinは嫌い MinGW+MSYS にしてみたい(けど未だによくわかってない) 事務PCなので, 大掛かりな環境は入れたくない(入れられない) WSL ? そもそも Windows7 なので(ry) などのモチベーションから 色々見ていてcmderが良さそうだなと思ったのですが cmder.net 所属機関でフィルタされて落とせなかった(つらい)ので, ConEmu + msys bash の組み合わせで端末環境を整える
Pythonユーザーが集まり、情報交換し、交流するためのカンファレンス「PyCon APAC 2013」が9月13日、14日に都内で開催されました。PyCon APACはこれまでシンガポールで開催されており、今回初めて日本で開催されました。 Pythonは日本ではあまり利用事例が多くありませんが、海外ではGoogleやDropboxなどで使われていることが知られ、人気のあるスクリプティング言語の1つです。Pycon APAC 2013の2日目の基調講演には、そのDropboxの3番目の社員であるRian Hunter氏が登壇、Dropboxの社内事例も交えてPythonの大規模開発について紹介しています。 基調講演の内容をダイジェストで紹介しましょう。 One Million Lines of Python このカンファレンスに呼んでいただけて大変光栄です。日本には初めて来ました。 僕が初
HTML5最近、Web フォントをつかってかっこいい表現をしているサイトも増えてきました。ただ、残念ながら 日本語で Web フォントを使うのは厳しいのが現実です。というのも、日本語には英数字・ひらがな・カタカナ・漢字・記号・・・など必要になる文字数が多すぎるため、フルスペックの日本語の Web フォントはファイルサイズがすごいことになりそうです。そこで、「利用したい文字だけを含んだ Web フォントをその都度作ればいいんじゃね?」ということを考えてみました。アイデア自体は珍しいものではなく、例えば デコもじ というサービスは同じようなことをやってくれるようです(ただし、無料では「書体 1 つまで」「5 文字まで」など機能制限が大きい)。手始めに日本語 Web フォントを作ってみるまずは簡単に日本語 Web フォントを作る方法を紹介しておきます。無料で公開されているフォントの中にも、フォン
古いエントリーなのですが、まだ時折検索エンジン経由?でいらっしゃる方がいるみたいなので追記 Titanium Desktopは今はTideSDKと変わってオープンソースプロジェクトになっています。 2月22日現在のTitanium Developer0.8.4&Desktop SDK 0.8.4をダウンロードしてインストールするとSDK欄がブランクでプロジェクトを作ることができないようです 解決C:\Program Files\Titanium Developer\manifestにsdk:0.8.4と追加して、アイコンをクリックすると再セットアップされます。情報元 さらに追記:Vista等では管理者権限があるユーザーを使用していても普通に開いたらこのファイルを編集できません。編集に使うエディタを右クリックして管理者権限で起動して、そこから manifestファイルを開いて編集してください
こんな質問を受けました Windows上のPython2.7を使っていて、手軽なデバッグ出力にprint文を使っているのだが、表示しようとしたユニコード文字列xにcp932で表現できない文字が含まれているとUnicodeEncodeErrorになってしまう。明示的にx.encode('cp932', 'replace')とかすれば大丈夫だが、全部の箇所にこれを書いて回るのはやりたくない。何かいい方法はないか? えっと、僕はMacを使っててコンソールもUTF-8なので問題ありません(ぇ というのはさておき、print文でユニコード文字列を表示しようとした際には、そのユニコード文字列を端末のエンコーディングでバイト列に変換(encode)しようとする。この時、デフォルトでは「変換できない文字があったら例外を投げる」(strict)モードになっている。 Python 2.7.1 (r271:86
CraftLaunch3自分はキーボード派なので、コマンドライン ランチャーを愛用している。歴史的には Moonlight → CraftLauch 2 という順に推移してきたのだけど、端末が変わったのをきっかけに CraftLaunch のサイトを見てみたら、いつのまにかメジャーバージョンアップして CraftLaunch 3 ができていた。この CraftLaunch 3 がなかなかプログラマ魂を刺激するもので、「設定ファイルは config.py」というアグレッシブなものになっている。ソースも公開されていて、コードのほとんど全てが Python で実装されている。ソースを参照しつつ config.py に拡張機能を書くことで、いろいろとカスタマイズできる。スクリプト言語でソフトウェアを作るということちょっと前に、「Lightroom は 40% のコードが Lua で、プラグインも
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く