通过运行命令安装 cassandra 驱动程序后:sudo pip3 install cassandra-driver
,我收到错误 ModuleNotFoundError: No module named 'cassandra'
当我尝试通过运行 cassandra
行来导入模块时.
然后我尝试查看pip3
中安装了哪些模块。通过运行命令 pip3 freeze
:
astroid==2.1.0
cassandra-driver==3.16.0
isort==4.3.4
lazy-object-proxy==1.3.1
mccabe==0.6.1
pylint==2.2.2
six==1.12.0
wrapt==1.10.11
看不到
cassandra
,我尝试导入可见模块:cassandra-driver
然后我得到了错误:File "<stdin>", line 1
import cassandra-driver
^
SyntaxError: invalid syntax
另外,当我用这个纠正连字符问题时:
__import__("cassandra-driver")
,我得到错误:Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'cassandra-driver'
我的
which python3
是:/usr/local/bin/python3
和我的which pip3
是:/usr/local/bin/pip3
我的操作系统是 MacOS
如何安装
cassandra
?注意:我关注 this文档。
最佳答案
您是否尝试运行这些演示(来自那些文档)?
“如果成功,您应该能够构建和安装扩展(只需使用 setup.py build 或 setup.py install),然后通过执行以下操作使用 libev 事件循环:”
>>> from cassandra.io.libevreactor import LibevConnection
>>> from cassandra.cluster import Cluster
>>> cluster = Cluster()
>>> cluster.connection_class = LibevConnection
>>> session = cluster.connect()
实际模块有可能以不同的方式命名,例如还有另一个名为 Pillow 的外部包,但您使用名称“PIL”导入它。
在文档中,他们正在导入
from cassandra.cluster
Docs I'm referring to
关于python-3.x - ModuleNotFoundError : No module named 'cassandra' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54163033/