我在Mac OS X 10.9.4上使用brew
安装了Cassandra:
➜ ~ 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:
我该如何解决?
答案 0 :(得分:5)
经过一些Google搜索和调试后,发现对locale.getpreferredencoding()
的调用需要22.2. locale — Internationalization services中所述LC_ALL
正确的LC_ALL
:
为了保持与其他平台的兼容性,不仅仅是LANG 变量被测试,但是作为envvars给出的变量列表 参数。将使用第一个被定义的定义。 envvars中 默认为GNU gettext中使用的搜索路径;它必须永远 包含变量名LANG。 GNU gettext搜索路径包含 'LANGUAGE','LC_ALL','LC_CTYPE'和'LANG',按顺序排列。
在我的系统pl_PL
上设置为➜ ~ echo $LC_ALL
pl_PL
:
LC_ALL
更改为pl
到pl_pl.utf-8
或cqlsh
后,Cassandra shell ➜ ~ 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>
就开始了:
python -c 'import locale, codecs; encoding = locale.getpreferredencoding(); print encoding; print codecs.lookup(encoding)'
请参阅线程Problem start cqlsh on OSX - Lion以获取示例Python应用程序以检查您的语言环境:
{{1}}
一旦工作正常,就可以解决问题。