【问题标题】:ModuleNotFoundError: No module named 'neo4j.addressing' and ModuleNotFoundError: No module named 'neo4j'ModuleNotFoundError:没有名为“neo4j.addressing”的模块和 ModuleNotFoundError:没有名为“neo4j”的模块
【发布时间】:2019-03-28 22:47:14
【问题描述】:

我收到此错误。只是尝试运行 Graph() 方法。

>>> import py2neo
>>> graph = py2neo.Graph()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "E:\Chibanggri\flask and neo4j\venv\lib\site-packages\py2neo\database.py", line 305, in __new__
database = Database(uri, **settings)
File "E:\Chibanggri\flask and neo4j\venv\lib\site-packages\py2neo\database.py", line 85, in __new__
connection_data = get_connection_data(uri, **settings)
File "E:\Chibanggri\flask and neo4j\venv\lib\site-packages\py2neo\internal\addressing.py", line 118, in get_connection_data
data["user_agent"] = http_user_agent() if data["scheme"] in ["http", "https"] else bolt_user_agent()
File "E:\Chibanggri\flask and neo4j\venv\lib\site-packages\py2neo\meta.py", line 32, in bolt_user_agent
import neo4j
ModuleNotFoundError: No module named 'neo4j'

这个错误没有neo4j-driver

>>> import py2neo
>>> graph = py2neo.Graph()
Traceback (most recent call last):
File "E:\Chibanggri\flask and neo4j\venv\lib\site-packages\py2neo\database.py", line 88, in __new__
inst = cls._instances[key]
KeyError: 'c562f33e637233f1922f80fc5652b53a'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "E:\Chibanggri\flask and neo4j\venv\lib\site-packages\py2neo\database.py", line 305, in __new__
database = Database(uri, **settings)
File "E:\Chibanggri\flask and neo4j\venv\lib\site-packages\py2neo\database.py", line 92, in __new__
from py2neo.internal.http import HTTPDriver, HTTPSDriver
File "E:\Chibanggri\flask and neo4j\venv\lib\site-packages\py2neo\internal\http.py", line 26, in <module>
from neo4j.addressing import SocketAddress
ModuleNotFoundError: No module named 'neo4j.addressing'

这个带有neo4j-driver 这是点冻结

astroid==2.0.4
bcrypt==3.1.4
cffi==1.11.5
Click==7.0
colorama==0.4.0
Flask==1.0.2
isort==4.3.4
ItsDangerous==1.0.0
Jinja2==2.10
lazy-object-proxy==1.3.1
MarkupSafe==1.0
mccabe==0.6.1
neobolt==1.7.0
neotime==1.7.1
passlib==1.7.1
py2neo==4.1.0
pycparser==2.19
pylint==2.1.1
pytz==2018.6
six==1.11.0
Werkzeug==0.14.1
wrapt==1.10.11 

这一切都在我为烧瓶教程设置的虚拟环境(venv)中。 问题似乎不是因为烧瓶,很可能是 neo4j 本身。我不知道该怎么办。

【问题讨论】:

  • 你试过独立导入neo4j吗?
  • 说的一样 >>> import neo4j Traceback(最近一次调用最后):文件“”,第 1 行,在 ModuleNotFoundError: No module named 'neo4j'
  • 我在需求文件中没有看到neo4j
  • 它在py2neo的meta.py文件中导入neo4j。
  • 你试过手动安装库吗?

标签: python neo4j py2neo


【解决方案1】:

pip install neo4j-driver==1.6.2

这应该可以解决问题。与 py2neo==4.1.0 一起安装的 neo4j-driver 似乎存在版本特定问题

【讨论】: