python code works fine on python shell but not through cmd when importing py2neo [duplicate]

為{幸葍}努か 提交于 2019-12-11 20:39:44

问题


as said in the title I'm having problem runnig my code from cmd which is working just fine in python shell.

I have py2neo version 4.

here is my code:

from py2neo import Graph
print ("passed")

here is the output from python shell:

passed
>>> 

here is the output from cmd command:

D:\py2neo>python py2neo.py

Traceback (most recent call last):
  File "py2neo.py", line 1, in <module>
    from py2neo import Graph
  File "D:\ALI\Desktop\ayten\mine-py2neo\py2neo.py", line 1, in <module>
    from py2neo import Graph
ImportError: cannot import name 'Graph'

I've been searching, the answer out there were the different versions of python that I have on my system, which has cause this problem. But I checked that out and realized that both of them have the same version.

here is how i figured out the versions:

opening the python shell:

Python 3.6.4 (v3.6.4:d48eceb, Dec 19 2017, 06:54:40) [MSC v.1900 64 bit (AMD64)] on win32
Type "copyright", "credits" or "license()" for more information.

>>> 

in cmd:

D:\py2neo>python --version
Python 3.6.4

D:\py2neo>python
Python 3.6.4 (v3.6.4:d48eceb, Dec 19 2017, 06:54:40) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>

Thank you in advance.


回答1:


Are you positive that py2neo is installed? What happens if you run pip install py2neo? I've had issues with pip and python versions in the past, so I would make sure that your pip is the same version as your python by running pip --version



来源:https://stackoverflow.com/questions/52226044/python-code-works-fine-on-python-shell-but-not-through-cmd-when-importing-py2neo

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!