【问题标题】:Python: pip can't find setup.pyPython:pip 找不到 setup.py
【发布时间】:2014-05-07 20:33:53
【问题描述】:

如何直接 pip 找到setup.py?我的setup.py 文件位于~/setuptools-3.5.1

我跑了

dustin@dustin:~$ python setuptools-3.5.1/setup.py egg_info
running egg_info
writing requirements to setuptools.egg-info/requires.txt
writing setuptools.egg-info/PKG-INFO
writing top-level names to setuptools.egg-info/top_level.txt
writing dependency_links to setuptools.egg-info/dependency_links.txt
writing entry points to setuptools.egg-info/entry_points.txt
reading manifest file 'setuptools.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
writing manifest file 'setuptools.egg-info/SOURCES.txt'
dustin@dustin:~$ 

所以看起来一切正常,但是当我运行 pip 时,我得到了

Command python setup.py egg_info failed with error code 1 in /tmp/pip_build_root/matplotlib
Storing debug log for failure in /home/dustin/.pip/pip.log

我的印象是,当我运行 pip 时,它没有找到 setup.py

【问题讨论】:

  • “我想要什么”部分很重要。它应该是一个在顶层带有 setup.py 的包。
  • 否,但matplotlib 必须是可安装 pip 的软件包。是吗?
  • 我知道,我以前也遇到过类似的问题。但我不确定它是否可以安装 pip。过去,我必须经历各种循环才能使用许多版本的 matplotlib。
  • /home/dustin/.pip/pip.log 说什么?
  • 您的系统似乎缺少freetypefreetype2

标签: python pip setuptools


【解决方案1】:

导航到包含您的 setup.py 的目录并运行:

pip install -e .

【讨论】:

  • 你不需要-e
  • 导航到setup.py 所在的目录,然后尝试安装不起作用。它产生同样的错误。
  • ls -lah - 您安装的用户的权限是否正确?
  • -rw-rw-rw- 1 dustin dustin 8.2K Apr 7 19:07 setup.py drwxrwxr-x 4 dustin dustin 4.0K May 7 16:26 setuptools drwxrwxr-x 2 dustin dustin 4.0K May 7 16:20 setuptools.egg-info drwxrwxr-x 3 dustin dustin 4.0K May 7 16:20 tests
  • 这是在 virtualenv 中还是你是 sudo 安装包?
【解决方案2】:

matplotlib 有很多外部依赖。其中一些是必需的。您可以在尝试的pip install 生成的日志文件中看到所需的列表。在你的情况下,是这样的:

REQUIRED DEPENDENCIES AND EXTENSIONS
                 numpy: yes [version 1.8.1]
              dateutil: yes [dateutil was not found. It is required for date
                        axis support. pip/easy_install may attempt to
                        install it after matplotlib.]
               tornado: yes [using tornado version 3.2.1]
             pyparsing: yes [pyparsing was not found. It is required for
                        mathtext support. pip/easy_install may attempt to
                        install it after matplotlib.]
                 pycxx: yes [Couldn't import.  Using local copy.]
                libagg: yes [pkg-config information for 'libagg' could not
                        be found. Using local copy.]
              freetype: no  [pkg-config information for 'freetype2' could
                        not be found.]
                   png: yes [pkg-config information for 'libpng' could not
                        be found. Using unknown version.]

还有

============================================================================
                        * The following required packages can not be built:
                        * freetype
Complete output from command python setup.py egg_info:
============================================================================

在这里,您可以看到找不到freetype。您需要在系统上安装它。

【讨论】:

    【解决方案3】:

    遇到了同样的问题。这可能是因为某些依赖项可能未安装。通过在 ubuntu 中使用包管理器安装解决了这个问题。使用以下命令

    sudo apt-get install python-matplotlib
    

    希望这会有所帮助。

    【讨论】:

      【解决方案4】:

      导航到包含您的 setup.py 的目录并运行:

      pip install -e.

      这对我有用。但是,当我在 anaconda 环境终端中使用“pip install -e '.[all]'”时,我仍然找不到按摩 setup.py。 相反,我使用了“pip install gym[all]”并且它起作用了!

      【讨论】:

        猜你喜欢
        • 2016-08-06
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2020-09-23
        • 1970-01-01
        • 2015-08-30
        • 2020-05-13
        • 1970-01-01
        相关资源
        最近更新 更多