Search code examples
pythonneo4jpy2neo

Cannot import Graph, Node, Relationship from py2neo


I cannot import py2neo's elements: Graph, Node, NodeSelector, Relationship

When I try to code it directly on the WinPython Commad Prompt it works just fine:

enter image description here

But when I type that in a file using Notepad++ and I try to run it on command prompt it dosen't work:

enter image description here

I have: Python 3.3.5, Neo4j 3.1.3 and py2neo 2.0.8. I had py2neo v3 before but it was not working for that version so I did a downgrade to v2 but abviously it doesn't work also for this version.


Solution

  • As far as I understand after a quick look to official Doc, WinPython does create a dedicated distribution of the Python programming language for Windows with its own local settings, in fact:

    You can install as many WinPython distributions as you want on the same machine: each one is isolated and self-consistent

    You installed py2neo in one of your WinPython environments and, as you mentioned, it works fine.

    When you try to run a python script by typing: python foo.py you are using your system interpreter which is not aware of packages inside WinPython environments.

    If you want to run files via command line, you have to install py2neo and all your packages in the path of your system interpreter. You can do it just by using pip (outside from the WinPython env!!) or just by roughly copying and pasting files (not recommended).