python-3.x - ModuleNotFoundError:没有名为“cassandra”的模块
问题描述
通过运行命令安装 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
看到 no 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
?注意:我正在关注此文档。
解决方案
您是否尝试运行这些演示(来自那些文档)?
“如果成功,您应该能够构建和安装扩展(只需使用 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
推荐阅读
- python - 为什么Python 3.6默认不安装wheel包?
- html - ul 列表中 li 元素之间的 CSS 间距
- python - 删除和释放单个 pandas 数据帧的内存
- ios - 更新 CellForRowAt / CellForItemAt 之外的单元格
- list - Swiftui:检测 onMove 开始
- python - Dynaconf 用 .secrets.toml 覆盖 settings.toml 中的部分
- flutter - 有没有办法按语言自定义 Flutter 可绘制元素?
- python - 如何找到我的其他行在 Pandas 中重复的行的 ID
- sql - 如何编写返回另一个表中不存在的数据的查询?
- c - 如何使用 scanf 避免缓冲区溢出