Import and Attribute Errors in py2neo conda environment


(Danieltpye) #1

Hello all,

I'm using py2neo in a conda environment. I import like this:

from py2neo import Graph, Node, Relationship

I have a neo4j instance in a graph object:

graph = Graph("bolt://localhost:7687",auth=("neo4j","password"))

The output of py2neo.__file__ is as expected I think.


Yet I get lots of errors when I try to run various attributes and other imports. For example, graph.nodes raises AttributeError: 'Graph' object has no attribute 'nodes'."Some Cypher query") works but if I try to apply anything like"MATCH (n) RETURN AS name").to_data_frame() or to_table() I get AttributeError: 'Cursor' object has no attribute 'to_data_frame'. However, I can run"MATCH (n) RETURN AS name").data() without issue.

I can also not import Database, NodeMatcher, and others.

ImportError                               Traceback (most recent call last)
<ipython-input-144-a35e0d35c939> in <module>
     12 import plotly.plotly as py
     13 import plotly.graph_objs as go
---> 14 from py2neo import Graph, Node, Relationship, NodeMatcher
     15 from folium.plugins import MarkerCluster, HeatMap, Fullscreen

ImportError: cannot import name 'NodeMatcher'

Could it be related to Anaconda? Any suggestions for steps I can take to identify the issue? I've already searched for answers on SO and elsewhere without a positive result.

(Nigel Small) #2

I don't know about conda specifically, but it sounds like you either have an old version or an import clash. Which version of py2neo did you install?

(Danieltpye) #3

I've got:

import py2neo


I tried a few different versions in different environments. For some reason, when I install version 4.0.0 in an environment with the python driver 1.6.2 installed, it downgrades it to 1.1.0. Is that normal?

My full environment is:

conda list

# packages in environment at /path/to/env:
# Name                    Version                   Build  Channel
altair                    2.3.0                 py36_1001    conda-forge
asn1crypto                0.24.0                py36_1003    conda-forge
attrs                     18.2.0                     py_0    conda-forge
backcall                  0.1.0                      py_0    conda-forge
blas                      1.0                         mkl
bleach                    3.1.0                    pypi_0    pypi
branca                    0.3.1                      py_0    conda-forge
ca-certificates           2018.11.29           ha4d7672_0    conda-forge
certifi                   2018.11.29            py36_1000    conda-forge
cffi                      1.11.5          py36h9745a5d_1001    conda-forge
chardet                   3.0.4                 py36_1003    conda-forge
cryptography              2.4.2            py36h1ba5d50_0
cycler                    0.10.0                     py_1    conda-forge
dbus                      1.13.6               h746ee38_0
decorator                 4.3.2                      py_0    conda-forge
entrypoints               0.3                   py36_1000    conda-forge
expat                     2.2.6                he6710b0_0
folium                    0.7.0                    pypi_0    pypi
fontconfig                2.13.0               h9420a91_0
freetype                  2.9.1                h8a8886c_1
fuzzywuzzy                0.17.0                     py_0    conda-forge
glib                      2.56.2               hd408876_0
gmp                       6.1.2             hf484d3e_1000    conda-forge
gst-plugins-base          1.14.0               hbbd80ab_1
gstreamer                 1.14.0               hb453b48_1
icu                       58.2                 h9c2bf20_1
idna                      2.8                   py36_1000    conda-forge
intel-openmp              2019.1                      144
ipykernel                 5.1.0           py36h24bf2e0_1002    conda-forge
ipython                   7.2.0           py36h24bf2e0_1000    conda-forge
ipython-cypher            0.2.6                    pypi_0    pypi
ipython_genutils          0.2.0                      py_1    conda-forge
jedi                      0.13.2                py36_1000    conda-forge
jinja2                    2.10                       py_1    conda-forge
jpeg                      9b                   h024ee3a_2
jsonschema                3.0.0a3               py36_1000    conda-forge
jupyter_client            5.2.4                      py_1    conda-forge
jupyter_core              4.4.0                      py_0    conda-forge
jupyterthemes             0.20.0                     py_0    conda-forge
kiwisolver                1.0.1           py36h6bb024c_1002    conda-forge
lesscpy                   0.13.0                     py_1    conda-forge
libedit                   3.1.20181209         hc058e9b_0
libffi                    3.2.1                hd88cf55_4
libgcc-ng                 8.2.0                hdf63c60_1
libgfortran-ng            7.3.0                hdf63c60_0
libpng                    1.6.36               hbc83047_0
libsodium                 1.0.16            h14c3975_1001    conda-forge
libstdcxx-ng              8.2.0                hdf63c60_1
libuuid                   1.0.3                h1bed415_2
libxcb                    1.13                 h1bed415_1
libxml2                   2.9.9                he19cac6_0
markupsafe                1.1.0           py36h14c3975_1000    conda-forge
matplotlib                3.0.2            py36h5429711_0
mistune                   0.8.4           py36h14c3975_1000    conda-forge
mkl                       2019.1                      144
mkl_fft                   1.0.10           py36h14c3975_1    conda-forge
mkl_random                1.0.2            py36h637b7d7_2    conda-forge
nbconvert                 5.3.1                      py_1    conda-forge
nbformat                  4.4.0                      py_1    conda-forge
ncurses                   6.1                  he6710b0_1
neo4j                     1.7.1                    pypi_0    pypi
neo4j-python-driver       1.1.0rc1                 py36_0    conda-forge
neo4jrestclient           2.1.1                    pypi_0    pypi
neobolt                   1.7.3                    pypi_0    pypi
neotime                   1.7.4                      py_0    conda-forge
networkx                  2.2                        py_1    conda-forge
notebook                  5.7.4                 py36_1000    conda-forge
numpy                     1.15.4           py36h7e9f1db_0
numpy-base                1.15.4           py36hde5b4d6_0
openssl                   1.1.1a            h14c3975_1000    conda-forge
pandas                    0.24.0           py36hf484d3e_0    conda-forge
pandoc                    2.6                           0    conda-forge
pandocfilters             1.4.2                      py_1    conda-forge
parso                     0.3.2                      py_0    conda-forge
pcre                      8.42                 h439df22_0
pexpect                   4.6.0                 py36_1000    conda-forge
pickleshare               0.7.5                 py36_1000    conda-forge
pip                       19.0.1                   py36_0    conda-forge
plotly                    3.5.0                      py_0    conda-forge
ply                       3.11                       py_1    conda-forge
prettytable               0.7.2                    pypi_0    pypi
prometheus_client         0.5.0                      py_0    conda-forge
prompt_toolkit            2.0.8                      py_0    conda-forge
ptyprocess                0.6.0                 py36_1000    conda-forge
py2neo                    4.0.0b2                  py36_0    conda-forge
pycparser                 2.19                       py_0    conda-forge
pygments                  2.3.1                      py_0    conda-forge
pyopenssl                 18.0.0                py36_1000    conda-forge
pyparsing                 2.3.1                      py_0    conda-forge
pyqt                      5.9.2            py36h05f1152_2
pyrsistent                0.14.9          py36h14c3975_1000    conda-forge
pysocks                   1.6.8                 py36_1002    conda-forge
python                    3.6.8                h0371630_0
python-dateutil           2.7.5                      py_0    conda-forge
python-levenshtein        0.12.0          py36h14c3975_1000    conda-forge
pytz                      2018.9                     py_0    conda-forge
pyzmq                     17.1.2          py36h6afc9c9_1001    conda-forge
qt                        5.9.7                h5867ecd_1
readline                  7.0                  h7b6447c_5
requests                  2.21.0                py36_1000    conda-forge
retrying                  1.3.3                      py_2    conda-forge
send2trash                1.5.0                      py_0    conda-forge
setuptools                40.7.1                   py36_0    conda-forge
sip                       4.19.8          py36hf484d3e_1000    conda-forge
six                       1.12.0                py36_1000    conda-forge
sqlite                    3.26.0               h7b6447c_0
terminado                 0.8.1                 py36_1001    conda-forge
testpath                  0.4.2                 py36_1000    conda-forge
tk                        8.6.8                hbc83047_0
toolz                     0.9.0                      py_1    conda-forge
tornado                   5.1.1           py36h14c3975_1000    conda-forge
traitlets                 4.3.2                 py36_1000    conda-forge
urllib3                   1.24.1                py36_1000    conda-forge
vincent                   0.4.4                      py_1    conda-forge
wcwidth                   0.1.7                      py_1    conda-forge
webencodings              0.5.1                      py_1    conda-forge
wheel                     0.32.3                   py36_0    conda-forge
xz                        5.2.4                h14c3975_4
zeromq                    4.2.5             hf484d3e_1006    conda-forge
zlib                      1.2.11               h7b6447c_3

(Nigel Small) #4

Yes, that is expected. Py2neo 4.0 works with the 1.1 driver, py2neo 4.1 works with the 1.6 driver and py2neo 4.2 works with the 1.7 driver (connector). So you'll need to upgrade your py2neo if you want a later version of the driver also installed.