2014-09-22 76 views
2

我已經在Mac OS X 10.9.4使用brew剛剛安裝卡桑德拉:爲什麼cqlsh會因LookupError失敗:未知編碼?

➜ ~ brew info cassandra 
cassandra: stable 2.1.0 
http://cassandra.apache.org 
/usr/local/Cellar/cassandra/2.0.9 (3466 files, 79M) * 
    Built from source 
From: https://github.com/Homebrew/homebrew/blob/master/Library/Formula/cassandra.rb 
==> Caveats 
If you plan to use the CQL shell (cqlsh), you will need the Python CQL library 
installed. Since Homebrew prefers using pip for Python packages, you can 
install that using: 

    pip install cql 

To have launchd start cassandra at login: 
    ln -sfv /usr/local/opt/cassandra/*.plist ~/Library/LaunchAgents 
Then to load cassandra now: 
    launchctl load ~/Library/LaunchAgents/homebrew.mxcl.cassandra.plist 
➜ ~ uname -a 
Darwin xxx 13.3.0 Darwin Kernel Version 13.3.0: Tue Jun 3 21:27:35 PDT 2014; root:xnu-2422.110.17~1/RELEASE_X86_64 x86_64 

如上信息消息通知,安裝cql我執行sudo easy_install pip其次pip install cql

隨着軟件安裝的,在執行cqlsh我面對錯誤:

➜ ~ cqlsh 
Traceback (most recent call last): 
    File "/usr/local/bin/cqlsh", line 2084, in <module> 
    main(*read_options(sys.argv[1:], os.environ)) 
    File "/usr/local/bin/cqlsh", line 2067, in main 
    single_statement=options.execute) 
    File "/usr/local/bin/cqlsh", line 509, in __init__ 
    self.output_codec = codecs.lookup(encoding) 
LookupError: unknown encoding: 

我怎樣才能解決呢?

回答

5

一些google搜索和調試後,事實證明,在調用locale.getpreferredencoding()預計適當LC_ALL22.2. locale — Internationalization services描述:

To maintain compatibility with other platforms, not only the LANG variable is tested, but a list of variables given as envvars parameter. The first found to be defined will be used. envvars defaults to the search path used in GNU gettext; it must always contain the variable name LANG. The GNU gettext search path contains 'LANGUAGE', 'LC_ALL', 'LC_CTYPE', and 'LANG', in that order.

在我的系統LC_ALL設置爲pl_PL

➜ ~ echo $LC_ALL 
pl_PL 

後改爲LC_ALL改爲plpl_pl.utf-8 Cassandra shell cqlsh啓動fi NE:

➜ ~ export LC_ALL=pl_pl.utf-8 
➜ ~ cqlsh 
Connected to Test Cluster at localhost:9160. 
[cqlsh 4.1.1 | Cassandra 2.0.9 | CQL spec 3.1.1 | Thrift protocol 19.39.0] 
Use HELP for help. 
cqlsh> 

見線程Problem start cqlsh on OSX - Lion對樣品Python應用程序來檢查您的語言環境:

python -c 'import locale, codecs; encoding = locale.getpreferredencoding(); print encoding; print codecs.lookup(encoding)' 

一旦它工作得很好,這個問題可以考慮解決。

+0

+1出色的發現,以及在追蹤解決方案方面的出色工作。 – Aaron 2014-09-22 19:06:50

相關問題