Enthought python包导入优先级

时间:2014-07-16 20:26:19

标签: python enthought

我使用venv从PyPI安装较新版本的elpy软件包,而不是root环境中提供的软件包。从pip查询,我看到elpy的以下版本:

~/python/standalone $ pip show elpy
---
Name: elpy
Version: 1.4.2
Location: /home/wdkrnls/python/env/local/lib/python2.7/site-packages
Requires: flake8

但是,使用解释器为我提供了根环境版本。

In [4]: import elpy
In [5]: elpy.__version__
Out[5]: '1.3.0'
In [6]: ?elpy
Type:       module
String Form:<module 'elpy' from '/home/ipython/Enthought2/lib/python2.7/site-packages/elpy/__init__.pyc'>
File:       /home/ipython/Enthought/lib/python2.7/site-packages/elpy/__init__.py
Docstring:
The Emacs Lisp Python Environment.

为什么会发生这种情况,我该如何解决?

我的sys.path很乱,而且我不知道如何清理它(我过去曾升级过Canopy发行版),但这里是:

['',
 '/home/wdkrnls/python/env/local/bin',
 '/home/wdkrnls/python/env/local/lib/python2.7/site-packages/jediepcserver-0.0.0-py2.7.egg',
 '/home/wdkrnls/python/env/local/lib/python2.7/site-packages/epc-0.0.5-py2.7.egg',
 '/home/wdkrnls/python/env/local/lib/python2.7/site-packages/sexpdata-0.0.3-py2.7.egg',
 '/home/ipython/Enthought2/lib/python2.7/site-packages/PyCifRW-3.3-py2.7-linux-x86_64.egg',
 '/home/ipython/Enthought2/lib/python2.7/site-packages/graphtool-0.5.2-py2.7.egg',
 '/home/ipython/Enthought2/lib/python2.7/site-packages',
 '/home/wdkrnls/python/env/local/lib/python2.7/site-packages/argparse-1.2.1-py2.7.egg',
 '/share/apps/python/Canopy/appdata/canopy-1.3.0.1715.rh5-x86_64/lib/python2.7/site-packages',
 '/home/ipython/Enthought/Canopy_64bit/User/lib/python2.7/site-packages',
 '/home/wdkrnls/python/packages',
 '/home/wdkrnls/python/standalone',
 '/share/apps/python/Canopy/appdata/canopy-1.3.0.1715.rh5-x86_64/lib/python27.zip',
 '/share/apps/python/Canopy/appdata/canopy-1.3.0.1715.rh5-x86_64/lib/python2.7',
 '/share/apps/python/Canopy/appdata/canopy-1.3.0.1715.rh5-x86_64/lib/python2.7/plat-linux2',
 '/share/apps/python/Canopy/appdata/canopy-1.3.0.1715.rh5-x86_64/lib/python2.7/lib-tk',
 '/share/apps/python/Canopy/appdata/canopy-1.3.0.1715.rh5-x86_64/lib/python2.7/lib-old',
 '/share/apps/python/Canopy/appdata/canopy-1.3.0.1715.rh5-x86_64/lib/python2.7/lib-dynload',
 '/home/wdkrnls/python/env/local/lib/python2.7/site-packages',
 '/home/ipython/Enthought2/lib/python2.7/site-packages/PIL',
 '/home/ipython/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/PIL',
 '/share/apps/python/Canopy/appdata/canopy-1.3.0.1715.rh5-x86_64/lib/python2.7/site-packages/IPython/extensions',
 '/home/wdkrnls/python/packages',
 '/home/wdkrnls/python/standalone']

我应该如何维护sys.path?我是否需要所有这些.egg文件进行Canopy分发?

2 个答案:

答案 0 :(得分:0)

看起来你正在使用ipython。如果你还没有在virtualenv中安装ipython,那么正在运行的ipython可执行文件将是系统的。

要检查,请将which ipythonwhich python进行比较。 Python可执行文件应该是virtualenv中的可执行文件。如果打赌ipython可执行文件是系统可执行文件。

答案 1 :(得分:0)

可以通过打印sys.path

找到优先顺序