IPython sys.path different from python sys.path

后端 未结 3 1236
渐次进展
渐次进展 2020-12-19 06:12

I generally use IPython and only recently noticed that the the search path for imports is wrong in the regular python shell. From what I understand, sys.path inherits from P

相关标签:
3条回答
  • 2020-12-19 06:49

    Probably too late for you now, but the answer here may help you too: ipython reads wrong python version . Basically the ipython script can directly reference a specific python binary rather than the one that you'd get if you just ran python directly.

    0 讨论(0)
  • 2020-12-19 06:55

    I had a brew installed version of Python on my mac. For some reason that couldn't use the system libraries. After brew uninstall python it worked again, because the default python was switched back to /usr/bin/python.

    Also playing around with which python, which ipython and opening up /usr/bin/python, /usr/local/bin/python, /usr/bin/ipython and /usr/local/bin/ipython and doing the imports there might help you find out where it is exactly going wrong.

    0 讨论(0)
  • 2020-12-19 07:00

    You may have your virtual environment activated which is ignoring the system path.

    It can be fixed by running this in terminal (After closing notebook etc):

    virtualenv --system-site-packages ~
    
    0 讨论(0)
提交回复
热议问题