0

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.

Benz
  • 249
  • 1
  • 13
  • Are you sure that the python interpreter of WinPython is the same of your system python? It seem like they are two different environments...Please, check it. – floatingpurr Apr 24 '17 at 16:50
  • @superciccio14 I've just resolved the problem, I had to change the file's location. I don't know why but it works. It seems like when I try to run it on command prompt the location where my file was was not allowing it to have access to py2neo so it can import Graph, Node, ... It's kinda like when you want to execute a program using Eclipse you have to put it in the workspace of Eclipse. Is it normal? – Benz Apr 25 '17 at 08:47
  • Probably you are using different version of the interpreter. Does winPython has its own version of Python? – floatingpurr Apr 25 '17 at 08:55
  • @superciccio14 No – Benz Apr 25 '17 at 11:48
  • from where and where did you copy the library to fix the problem? – floatingpurr Apr 25 '17 at 22:30
  • @superciccio14 it was in Documents and I copied it to py2neo's folder – Benz Apr 26 '17 at 12:31

1 Answers1

1

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).

Community
  • 1
  • 1
floatingpurr
  • 5,024
  • 5
  • 30
  • 79