2013-01-10 57 views
2
下面

是說明問題的一個終端會話:爲什麼setup.py顯然成功安裝我的軟件包,但實際上無法安裝依賴項?

$ 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)[email protected]:~/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. 開始的virtualenv與mkvirtualenv test
  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='[email protected]', 
    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() 
) 

任何想法,這是怎麼回事?

+0

您是否嘗試過手動安裝guessit? – asermax

+0

@酶,是的,它沒有問題的作品。但是,我試圖分發這個包,所以我確實需要setuptools才能正常工作。 – blz

+0

嘗試使用絕對路徑運行'pip',也許你的系統使用了錯誤的'pip'。它應該是由virtualenv安裝的。 – Dikei

回答

4

默認情況下,新的virtualenv不包括安裝在其外的軟件包(創建時沒有--system-site-packages選項)。因此,您的test virtualenv不會看到安裝到~/.local的軟件包(由於--user選項)。

可以使用--system-site-packages選項創建virtualenv,或者在激活的virtualenv中安裝時不使用--user。

+0

這是打算。我想確保依賴關係是由setuptools自動解決的。 setuptools不應該自動下載缺少的pip包嗎?當然似乎是這樣做的。另外,我只注意到我忘了將我的setup.py文件添加到問題中,所以我現在要做。 – blz

+0

@blz:Python中的'import'語句通常不會安裝模塊。輸出顯示的'pip install'不下載依賴關係。 *「要麼使用--system-site-packages選項創建virtualenv,要麼在激活的virtualenv中安裝時不使用--user。」* – jfs

0

我也有類似的問題,這是一個發行版問題 當我使用下面的安裝 -

sudo apt-get install python-scrapy 

命令行它的工作。請確保在點擊上述命令之前更新您的存儲庫以獲取當前版本

+0

我正在開發'Scrappy',而不是'scrapy'。不可否認,這個名稱有助於解決一些混淆問題,但請注意額外的'p'=) – blz

+0

@blz - 抱歉誤解! – minocha

+0

不用擔心!正因爲這個原因,我應該爲項目選擇另一個名字! – blz

相關問題