IPython sys.path与python sys.path不同 [英] IPython sys.path different from python sys.path

查看:190
本文介绍了IPython sys.path与python sys.path不同的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我通常使用IPython,并且最近才注意到常规python shell中导入的搜索路径是错误的。根据我的理解,sys.path继承自PYTHONPATH(尽管我不知道PYTHONPATH在哪里生活),这在IPython中是不同的?我担心这个有影响的装置。例如我刚试过

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

失败了,因为它无法解决我已安装的scipy依赖项。
所以我深入了一点,发现在Ipython中

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__

在python中返回.9.1

returns .9.1 while in python

import gensim
gensim.__version__

返回.8.9

以下是Ipython版本的sys.path的样子:

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']

和常规python脚本sys.path:

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']


推荐答案

现在可能为时已晚,但这里的答案也可能对您有所帮助: ipython读取错误的python版本。基本上,ipython脚本可以直接引用特定的python二进制文件,而不是你直接运行python时获得的那个。

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.

这篇关于IPython sys.path与python sys.path不同的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆