为什么cqlsh因LookupError而失败:未知编码?

 一叶之秋 发布于 2022-12-20 11:21

我刚刚brew在Mac OS X 10.9.4上安装了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 
    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:

我该如何解决?

1 个回答
  • 经过一些谷歌搜索和调试后,结果表明调用locale.getpreferredencoding()期望正确LC_ALL,如22.2所述.locale - 国际化服务:

    为了保持与其他平台的兼容性,不仅测试了LANG变量,还测试了以envvars参数给出的变量列表.将使用第一个被定义的定义.envvars默认使用GNU gettext中使用的搜索路径; 它必须始终包含变量名LANG.GNU gettext搜索路径按顺序包含"LANGUAGE","LC_ALL","LC_CTYPE"和"LANG".

    在我的系统LC_ALL上设置为pl_PL:

    ?  ~  echo $LC_ALL
    pl_PL
    

    更改后LC_ALLplpl_pl.utf-8卡桑德拉壳cqlsh开始罚款:

    ?  ~  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>
    

    请参阅OSX上的线程问题启动cqlsh -用于检查您的语言环境的示例Python应用程序的Lion:

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

    一旦它工作正常,可以考虑解决问题.

    2022-12-20 11:23 回答
撰写答案
今天,你开发时遇到什么问题呢?
立即提问
热门标签
PHP1.CN | 中国最专业的PHP中文社区 | PNG素材下载 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有