如何在Enthought Python中安装外部包?

时间:2014-10-01 18:08:41

标签: python windows-7 installation enthought

我试图在我的Enthought python安装下(在windows7下)安装rpy2与Ipython一起使用,但是无法使其工作(我第一次尝试安装外部软件包)。根据我的理解,可以在Enthought下使用pip来安装外部包(参见例如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之后,我尝试安装distributeenpkg 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):

1 个答案:

答案 0 :(得分: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