2014-09-22 79 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

相关问题