python - 为什么 setup.py 表面上成功安装了我的包,但实际上却未能安装依赖项?

标签 python pip setuptools

下面是说明问题的终端 session :

$ pip install scrappy --user
Requirement already satisfied (use --upgrade to upgrade): scrappy in /home/louist/Documents/Python/Scrappy
Downloading/unpacking guessit (from scrappy)
  Downloading guessit-0.5.3.tar.gz (45Kb): 45Kb downloaded
  Running setup.py egg_info for package guessit

Downloading/unpacking tvdb-api (from scrappy)
  Downloading tvdb_api-1.8.2.tar.gz
  Running setup.py egg_info for package tvdb-api

Downloading/unpacking hachoir-metadata (from scrappy)
  Downloading hachoir-metadata-1.3.3.tar.gz (52Kb): 52Kb downloaded
  Running setup.py egg_info for package hachoir-metadata
    Warning: unable to recompile dialog.ui to dialog_ui.py using pyuic4
    (use command "-c egg_info --egg-base pip-egg-info --disable-qt" to disable this warning)


Downloading/unpacking hachoir-core (from scrappy)
  Downloading hachoir-core-1.3.3.tar.gz (91Kb): 91Kb downloaded
  Running setup.py egg_info for package hachoir-core

Downloading/unpacking hachoir-parser (from scrappy)
  Downloading hachoir-parser-1.3.4.tar.gz (359Kb): 359Kb downloaded
  Running setup.py egg_info for package hachoir-parser

    warning: no files found matching 'metadata_csv.py'
Installing collected packages: guessit, tvdb-api, hachoir-metadata, hachoir-core, hachoir-parser
  Running setup.py install for guessit

  Running setup.py install for tvdb-api

  Running setup.py install for hachoir-metadata
    Warning: unable to recompile dialog.ui to dialog_ui.py using pyuic4
    (use command "-c install --single-version-externally-managed --record /tmp/pip-3OxvBD-record/install-record.txt --install-headers /home/louist/.virtualenvs/test/include/site/python2.7 --user --disable-qt" to disable this warning)

    changing mode of build/scripts-2.7/hachoir-metadata from 664 to 775
    changing mode of build/scripts-2.7/hachoir-metadata-gtk from 664 to 775
    changing mode of build/scripts-2.7/hachoir-metadata-qt from 664 to 775
    deleting hachoir_metadata.egg-info/requires.txt

    changing mode of /home/louist/.local/bin/hachoir-metadata to 775
    changing mode of /home/louist/.local/bin/hachoir-metadata-gtk to 775
    changing mode of /home/louist/.local/bin/hachoir-metadata-qt to 775
  Running setup.py install for hachoir-core

  Running setup.py install for hachoir-parser
    deleting hachoir_parser.egg-info/requires.txt

    warning: no files found matching 'metadata_csv.py'
Successfully installed guessit tvdb-api hachoir-metadata hachoir-core hachoir-parser
Cleaning up...
(test)louist@ltpc:~/Documents/Python/Scrappy$ python
Python 2.7.3 (default, Sep 26 2012, 21:51:14) 
[GCC 4.7.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import scrappy.core as scrappy
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "scrappy/core.py", line 10, in <module>
    import guessit
ImportError: No module named guessit

简而言之,我做了以下事情:

  1. 使用 mkvirtualenv test 启动 virtualenv
  2. 尝试通过 pip install scrappy --user 安装我正在开发的软件包
  3. 启动 python 终端,然后尝试导入 scrappy.core

这是我的 setup.py 文件:

#!/usr/bin/env python
from setuptools import setup

setup(
    name='Scrappy',
    version="0.2.7 alpha",
    author='Louis Thibault',
    author_email='<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="b0dcdfc5d9c3c48887f0d7ddd1d9dc9ed3dfdd" rel="noreferrer noopener nofollow">[email protected]</a>',
    packages=['scrappy'],
    include_package_data=True,
    install_requires=['guessit', 'tvdb_api', 'hachoir-metadata', 'hachoir-core', 'hachoir-parser'],
    url='https://github.com/louist87/scrappy',
    license='GPL 3.0',
    description='Rename video files based on information scraped from thetvdb.com',
    keywords=["TVDB", "thetvdb", "rename", "broadcatching", "media"],
    long_description=open('README.rst').read()
)

对发生的事情有什么想法吗?

最佳答案

默认情况下,新的 virtualenv 不包含在其外部安装的软件包(在没有 --system-site-packages 选项的情况下创建)。因此,您的 test virtualenv 不会看到安装到 ~/.local 的软件包(由于 --user 选项)。

使用 --system-site-packages 选项创建 virtualenv,或者在激活的 virtualenv 中安装时不使用 --user。

关于python - 为什么 setup.py 表面上成功安装了我的包,但实际上却未能安装依赖项?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14249367/

相关文章:

python - ValueError : Classification metrics can't handle a mix of multilabel-indicator on pretrained CNN

python - 尝试安装 Scrapy - 错误 : Could not find 'openssl.exe'

python - 允许 python 包要求在设置中失败

python - DevStack 安装错误 : Directory 'opt/stack/nova' is not installable

python - 虚拟环境中的 Pip 升级访问被拒绝

python - 在 Docker 中设置 cassandra 驱动程序(python)

Python 守护进程打包最佳实践

javascript - 如何在 Django 应用程序中的 Javascript、Python 和 CSS 之间共享配置数据?

python - 如何从实验室图像中删除 L channel

python - 使用 python 3.5.0 在 Windows 8 上提取 Pdf 文本