gpt4 book ai didi

python - Enthought python包导入优先级

转载 作者:行者123 更新时间:2023-11-28 19:21:05 24 4
gpt4 key购买 nike

我正在使用 venv 从 PyPI 安装比根环境中可用的更新版本的 elpy 包。从 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 吗?

最佳答案

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

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

关于python - Enthought python包导入优先级,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24790021/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com