在通过运行命令sudo pip3 install cassandra-driver安装cassandra驱动程序之后,当我尝试通过运行cassandra行来导入模块时,我得到错误ModuleNotFoundError: No module named 'cassandra'。
然后,我尝试通过运行命令pip3 freeze来查看pip3中安装了哪些模块
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文档。
发布于 2019-01-13 03:42:09
你有没有试着运行这些演示(从那些文档中)?
如果成功,您应该能够构建和安装扩展(只需使用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
发布于 2021-05-19 17:28:19
$ echo 'import cassandra.cluster' > cassandra.py && python3 cassandra.py
Traceback (most recent call last):
File "./cassandra.py", line 3, in <module>
import cassandra
File "/home/xxx/cassandra.py", line 4, in <module>
import cassandra.cluster
ModuleNotFoundError: No module named 'cassandra.cluster'; 'cassandra' is not a package使用不同的文件名,错误将消失:
echo 'import cassandra.cluster' > tmp.py && python3 cassandra.py所以,对我来说,错误是我自己的程序覆盖了包。O.o
https://stackoverflow.com/questions/54163033
复制相似问题