Python2.7.18已安装six仍触发cqlsh报错‘ModuleNotFoundError: No module named 'six.moves'’的问题及解决方法
Python2.7.18已安装six仍触发cqlsh报错‘ModuleNotFoundError: No module named 'six.moves'’的问题及解决方法
我看你已经在Python 2.7.18环境里用pip安装了six 1.7.2,但运行cqlsh时还是触发了ModuleNotFoundError: No module named 'six.moves'的错误,先看看你这边的具体操作和反馈:
首先是当前Python版本:
seva@seva-HLYL-WXX9:~$ python --version Python 2.7.18
然后尝试安装six的反馈,显示已经安装:
seva@seva-HLYL-WXX9:~$ pip install six==1.7.2 DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. pip 21.0 will drop support for Python 2.7 in January 2021. More details about Python 2 support in pip can be found in pip's official documentation. pip 21.0 will remove support for this functionality. Requirement already satisfied: six==1.7.2 in ./.pyenv/versions/2.7.18/lib/python2.7/site-packages (1.7.2)
运行cqlsh时的报错:
seva@seva-HLYL-WXX9:~$ cqlsh Traceback (most recent call last): File "/usr/bin/cqlsh.py", line 130, in <module> from six.moves import configparser, input ModuleNotFoundError: No module named 'six.moves'
查看six的安装信息,确认确实安装在Python2.7的site-packages目录:
seva@seva-HLYL-WXX9:~$ pip show six DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. pip 21.0 will drop support for Python 2.7 in January 2021. More details about Python 2 support in pip can be found in pip's official documentation. pip 21.0 will remove support for this functionality. Name: six Version: 1.7.2 Summary: Python 2 and 3 compatibility utilities Home-page: PyPI上的six项目页面 Author: Benjamin Peterson Author-email: benjamin@python.org License: MIT Location: /home/seva/.pyenv/versions/2.7.18/lib/python2.7/site-packages Requires: Required-by: thrift
解决方法
这个问题的核心是cqlsh默认调用的Python版本和你安装six的版本不匹配,咱们可以修改cqlsh的脚本指定Python版本:
- 打开cqlsh.py脚本文件,用nano编辑器的话可以执行这条命令:
sudo nano /usr/bin/cqlsh.py
- 在脚本开头找到指定Python解释器的行(一般是
#!/usr/bin/env python3这类格式),把python3改成python2.7,保存退出后再运行cqlsh应该就能正常使用了。
备注:内容来源于stack exchange,提问作者Steffano Aravico
相关产品推荐
相关产品推荐

