【问题标题】:How to install external packages in Enthought Python?如何在 Enthought Python 中安装外部包?
【发布时间】:2014-11-26 16:07:56
【问题描述】:

我正在尝试在我的 Enthought python 安装(在 windows7 下)下安装 rpy2 以与 Ipython 一起使用,但无法使其正常工作(我第一次尝试安装外部软件包)。据我了解 pip 可以在 Enthought 下使用来安装外部包(参见例如Using non-EPD package installers such as pip),并且该包似乎已下载。 EPD-python 也是我路径中的第一个,所以这应该不是问题。但是,在安装过程中,我得到了error: invalid command 'egg_info'

我还尝试了此 Q 中的建议,以明确为 PATH 加上前缀:Install a Python package into a different directory using pip?(但问题似乎并不在于路径问题)。

我还在invalid command 'egg_info' 错误中看到this Q,建议升级setuptools,但Enthought 明确警告不要弄乱其他版本的setuptools(请参阅Installing packages into Canopy User Python from the OS command line)-也许这是过时的信息?

这可能是一个微不足道的问题,但我无法解决这个问题。

命令:

pip install rpy2

日志文件的一部分粘贴在下面:

Downloading from URL https://pypi.python.org/packages/source/r/rpy2/rpy2-2.4.3.tar.gz#md5=57e3fda409226dffb543c913c8553cdc (from https://pypi.python.org/simple/rpy2/)
  Running setup.py (path:c:\users\tobjep\appdata\local\temp\pip_build_tobjep\rpy2\setup.py) egg_info for package rpy2
    usage: -c [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
       or: -c --help [cmd1 cmd2 ...]
       or: -c --help-commands
       or: -c cmd --help

    error: invalid command 'egg_info'
    Complete output from command python setup.py egg_info:
    usage: -c [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]

   or: -c --help [cmd1 cmd2 ...]

   or: -c --help-commands

   or: -c cmd --help

error: invalid command 'egg_info'

----------------------------------------
Cleaning up...
  Removing temporary dir c:\users\tobjep\appdata\local\temp\pip_build_tobjep...
Command python setup.py egg_info failed with error code 1 in c:\users\tobjep\appdata\local\temp\pip_build_tobjep\rpy2
Exception information:
Traceback (most recent call last):
  File "C:\Program_\EPD_python27\lib\site-packages\pip\basecommand.py", line 122, in main
    status = self.run(options, args)
  File "C:\Program_\EPD_python27\lib\site-packages\pip\commands\install.py", line 278, in run
    requirement_set.prepare_files(finder, force_root_egg_info=self.bundle, bundle=self.bundle)
  File "C:\Program_\EPD_python27\lib\site-packages\pip\req.py", line 1229, in prepare_files
    req_to_install.run_egg_info()
  File "C:\Program_\EPD_python27\lib\site-packages\pip\req.py", line 325, in run_egg_info
    command_desc='python setup.py egg_info')
  File "C:\Program_\EPD_python27\lib\site-packages\pip\util.py", line 697, in call_subprocess
    % (command_desc, proc.returncode, cwd))
InstallationError: Command python setup.py egg_info failed with error code 1 in c:\users\tobjep\appdata\local\temp\pip_build_tobjep\rpy2

更新:other advice 之后,我尝试安装distribute (enpkg distribute),然后重新安装pip。在此之后 rpy2 的安装仍然失败,但现在出现错误 NameError: name 'sys_platform' is not defined:

Traceback (most recent call last):
  File "<string>", line 17, in <module>
  File "c:\users\tobjep\appdata\local\temp\pip_build_tobjep\rpy2\setup.py", line 447, in <module>
    'rpy2': ['doc/source/rpy2_logo.png', ]}
  File "C:\Program_\EPD_python27\lib\distutils\core.py", line 112, in setup
    _setup_distribution = dist = klass(attrs)
  File "C:\Program_\EPD_python27\lib\site-packages\setuptools\dist.py", line 225, in __init__
    _Distribution.__init__(self,attrs)
  File "C:\Program_\EPD_python27\lib\distutils\dist.py", line 287, in __init__
    self.finalize_options()
  File "C:\Program_\EPD_python27\lib\site-packages\setuptools\dist.py", line 257, in finalize_options
    ep.require(installer=self.fetch_build_egg)
  File "C:\Program_\EPD_python27\lib\site-packages\pkg_resources.py", line 2099, in require
    working_set.resolve(self.dist.requires(self.extras),env,installer))
  File "C:\Program_\EPD_python27\lib\site-packages\pkg_resources.py", line 2309, in requires
    dm = self._dep_map
  File "C:\Program_\EPD_python27\lib\site-packages\pkg_resources.py", line 2538, in _dep_map
    self.__dep_map = self._compute_dependencies()
  File "C:\Program_\EPD_python27\lib\site-packages\pkg_resources.py", line 2571, in _compute_dependencies
    common = frozenset(reqs_for_extra(None))
  File "C:\Program_\EPD_python27\lib\site-packages\pkg_resources.py", line 2568, in reqs_for_extra
    if req.marker_fn(override={'extra':extra}):
  File "C:\Program_\EPD_python27\lib\site-packages\_markerlib\markers.py", line 109, in marker_fn
    return eval(compiled_marker, environment)
  File "<environment marker>", line 1, in <module>
NameError: name 'sys_platform' is not defined
Complete output from command python setup.py egg_info:
Traceback (most recent call last):

【问题讨论】:

  • 在某种程度上,问题仍然存在。但是,我使用 Enthought python 找到的 windows 二进制文件成功安装了 rpy2。现在有了RuntimeError: R_HOME not defined 的问题,甚至认为 R_HOME 已定义。叹息……

标签: python windows-7 installation enthought


【解决方案1】:

rpy2 据说很难在 Windows 上构建。

目前我最好的建议是尝试安装 Chris Gohlke 的实验性二进制构建: http://www.lfd.uci.edu/~gohlke/pythonlibs/#rpy2

由于他的安装程序使用 Windows 注册表指向 Python,您实际上应该在 Canopy 首选项中将 Canopy 设为默认 Python,而不仅仅是使用 Canopy 命令提示符窗口。您链接的文章中对此进行了描述: https://support.enthought.com/entries/23389761-Installing-packages-into-Canopy-Python-from-the-command-line

【讨论】:

  • 我刚刚这样做了 - 请参阅上面的评论。这似乎可行,但我现在从 Ipython 中获得 RuntimeError: R_HOME not defined,即使定义了 R_HOME。
  • 正如我在 Q EDP-python 中所写的那样,是我的主要 python 安装,首先在我的路径中。
猜你喜欢
  • 2016-02-05
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-04-18
  • 2013-04-22
  • 2018-10-31
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多