当我尝试运行 Travis-CI 测试时,为什么我的模块无法导入?

2024-04-19 20:36:48 发布

您现在位置:Python中文网/ 问答频道 /正文

我试着在我做的模块上运行Travis CI。noestests在我的本地计算机上以惊人的速度通过,但是由于某些原因,test.py文件无法导入我的项目。以下是Travis CI的完整输出:

Using worker: ppp3.worker.travis-ci.org:php-4

$ cd ~/builds
$ git clone --branch=master --depth=100 --quiet git://github.com/louist87/Scrappy.git louist87/Scrappy
$ cd louist87/Scrappy
$ git checkout -qf 68d1291c8a81638554d036aa01215632a6661623
$ source ~/virtualenv/python2.7/bin/activate
$ python --version
Python 2.7.3
$ pip --version
pip 1.2.1 from /home/travis/virtualenv/python2.7/lib/python2.7/site-packages/pip-1.2.1-py2.7.egg (python 2.7)
$ pip install -r requirements.txt --use-mirrors
Downloading/unpacking guessit>=0.5.2 (from -r requirements.txt (line 1))
  Downloading guessit-0.5.3.tar.gz (45kB): 45kB downloaded
  Running setup.py egg_info for package guessit

Downloading/unpacking tvdb-api>=1.8.2 (from -r requirements.txt (line 2))
  Downloading tvdb_api-1.8.2.tar.gz
  Running setup.py egg_info for package tvdb-api

Downloading/unpacking hachoir-metadata>=1.3.3 (from -r requirements.txt (line 3))
  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>=1.3.3 (from -r requirements.txt (line 4))
  Downloading hachoir-core-1.3.3.tar.gz (91kB): 91kB downloaded
  Running setup.py egg_info for package hachoir-core

Downloading/unpacking hachoir-parser>=1.3.4 (from -r requirements.txt (line 5))
  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 --record /tmp/pip-Xc_ilb-record/install-record.txt --single-version-externally-managed --install-headers /home/travis/virtualenv/python2.7/include/site/python2.7 --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/travis/virtualenv/python2.7/bin/hachoir-metadata-qt to 775
    changing mode of /home/travis/virtualenv/python2.7/bin/hachoir-metadata to 775
    changing mode of /home/travis/virtualenv/python2.7/bin/hachoir-metadata-gtk 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...
$ nosetests -w tests/
E
======================================================================
ERROR: Failure: ImportError (No module named scrappy.core)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/travis/virtualenv/python2.7/local/lib/python2.7/site-packages/nose/loader.py", line 390, in loadTestsFromName
    addr.filename, addr.module)
  File "/home/travis/virtualenv/python2.7/local/lib/python2.7/site-packages/nose/importer.py", line 39, in importFromPath
    return self.importFromDir(dir_path, fqname)
  File "/home/travis/virtualenv/python2.7/local/lib/python2.7/site-packages/nose/importer.py", line 86, in importFromDir
    mod = load_module(part_fqname, fh, filename, desc)
  File "/home/travis/builds/louist87/Scrappy/tests/test.py", line 8, in <module>
    import scrappy.core as scrappy
ImportError: No module named scrappy.core

----------------------------------------------------------------------
Ran 1 test in 0.004s

FAILED (errors=1)

Done. Build script exited with: 1

注意,Scrappy是我项目的名称,这就是导入失败的原因。在

这是我的.travis.yml文件:

^{pr2}$

你知道怎么回事吗?在


Tags: installtofrompytxttravishomefor
1条回答
网友
1楼 · 发布于 2024-04-19 20:36:48

好的,这样看来travisci在安装目标包时不会执行隐式develop。在

通过将YAML文件中的script行编辑为:

script:  "python setup.py develop && nosetests -w tests/"

相关问题 更多 >