Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
641 views
in Technique[技术] by (71.8m points)

import - IPython sys.path different from python sys.path

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 PYTHONPATH (although I don't know where PYTHONPATH lives), is this different in IPython? I'm worried that this effecting installations. For instance I just tried

pip install --upgrade gensim

which failed because it couldn't resolve the scipy dependency, which I already have installed. So I dove a little bit deeper and found in Ipython

import gensim
gensim.__version__

returns .9.1 while in python

import gensim
gensim.__version__

returns .8.9

Here is what the Ipython version of sys.path looks like:

['',
    '/Users/change/anaconda/bin',
    '/Users/change/anaconda/lib/python2.7/site-packages/pybing-0.12-py2.7.egg',
    '/Users/change/anaconda/lib/python2.7/site-packages/httplib2-0.8-py2.7.egg',
    '/Users/change/anaconda/python.app/Contents/lib/python27.zip',
    '/Users/change/anaconda/python.app/Contents/lib/python2.7',
    '/Users/change/anaconda/python.app/Contents/lib/python2.7/plat-darwin',
    '/Users/change/anaconda/python.app/Contents/lib/python2.7/plat-mac',
    '/Users/change/anaconda/python.app/Contents/lib/python2.7/plat-mac/lib-scriptpackages',
    '/Users/change/anaconda/python.app/Contents/lib/python2.7/lib-tk',
    '/Users/change/anaconda/python.app/Contents/lib/python2.7/lib-old',
    '/Users/change/anaconda/python.app/Contents/lib/python2.7/lib-dynload',
    '/Users/change/anaconda/lib/python2.7/site-packages',
    '/Users/change/anaconda/lib/python2.7/site-packages/PIL',
    '/Users/change/anaconda/lib/python2.7/site-packages/pygoogle',
    '/Users/change/anaconda/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg-info',
    '/Users/change/anaconda/lib/python2.7/site-packages/IPython/extensions']

and the regular python script sys.path:

['',
'/Users/change/anaconda/lib/python2.7/site-packages/pybing-0.12-py2.7.egg',
'/Users/change/anaconda/lib/python2.7/site-packages/httplib2-0.8-py2.7.egg',
'/Users/change/anaconda/lib/python27.zip',
'/Users/change/anaconda/lib/python2.7',
'/Users/change/anaconda/lib/python2.7/plat-darwin',
'/Users/change/anaconda/lib/python2.7/plat-mac',
'/Users/change/anaconda/lib/python2.7/plat-mac/lib-scriptpackages',
'/Users/change/anaconda/lib/python2.7/lib-tk',
'/Users/change/anaconda/lib/python2.7/lib-old',
'/Users/change/anaconda/lib/python2.7/lib-dynload',
'/Users/change/anaconda/lib/python2.7/site-packages',
'/Users/change/anaconda/lib/python2.7/site-packages/PIL',
'/Users/change/anaconda/lib/python2.7/site-packages/pygoogle',
'/Users/change/anaconda/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg-info']
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

56.8k users

...