2

我有一个具有 Python 3.4 依赖项(外部命令)的 go 项目。我有一组称为reqs.txt. 我使用 virtualenv 来确保我在自己的 venv 中,所以我可以安装我的依赖项。

我收到以下错误(下面的完整日志):

    ImportError: No module named 'six'

这是令人沮丧的,因为就在这一行之前,有一个six软件包的安装。

我的 .travis.yml 文件

sudo: required
language: go
go:
  - 1.7
addons:
  apt:
    sources:
      - deadsnakes # source required so it finds the package definition below
    packages:
      - python3.4
before_install:
  - go get github.com/axw/gocov/gocov
  - go get github.com/mattn/goveralls
  - if ! go get code.google.com/p/go.tools/cmd/cover; then go get golang.org/x/tools/cmd/cover; fi
  - sudo pip install virtualenv
  - virtualenv -p `which python3.4` .venv
  - source .venv/bin/activate
  - python -V
  - pip -V
  - pip install -r cmd/refframes/reqs.txt
  - wget -O cmd/refframes/spicekernels/de430.bsp https://naif.jpl.nasa.gov/pub/naif/generic_kernels/spk/planets/de430.bsp
script:
  - python cmd/refframes/tests.py
  - go test -v -timeout=30m -covermode=count -coverprofile=coverage.out
  #- $HOME/gopath/bin/goveralls -coverprofile=coverage.out -service=travis-ci
  - $HOME/gopath/bin/goveralls -package github.com/ChristopherRabotin/smd -service=travis-ci

特拉维斯日志

$ pip install -r cmd/refframes/reqs.txt
You are using pip version 6.0.7, however version 9.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
Collecting appdirs==1.4.0 (from -r cmd/refframes/reqs.txt (line 1))
  Downloading appdirs-1.4.0-py2.py3-none-any.whl
Collecting numpy==1.12.0 (from -r cmd/refframes/reqs.txt (line 2))
  Downloading numpy-1.12.0.zip (4.8MB)
    100% |################################| 4.8MB 127kB/s 
    Running from numpy source directory.
Collecting packaging==16.8 (from -r cmd/refframes/reqs.txt (line 3))
  Downloading packaging-16.8-py2.py3-none-any.whl
Collecting py==1.4.32 (from -r cmd/refframes/reqs.txt (line 4))
  Downloading py-1.4.32-py2.py3-none-any.whl (82kB)
    100% |################################| 86kB 5.0MB/s 
Collecting pyparsing==2.1.10 (from -r cmd/refframes/reqs.txt (line 5))
  Downloading pyparsing-2.1.10-py2.py3-none-any.whl (56kB)
    100% |################################| 57kB 6.5MB/s 
Collecting pytest==3.0.6 (from -r cmd/refframes/reqs.txt (line 6))
  Downloading pytest-3.0.6-py2.py3-none-any.whl (172kB)
    100% |################################| 176kB 2.9MB/s 
Collecting six==1.10.0 (from -r cmd/refframes/reqs.txt (line 7))
  Downloading six-1.10.0-py2.py3-none-any.whl
Collecting spiceypy==1.1.0 (from -r cmd/refframes/reqs.txt (line 8))
  Downloading spiceypy-1.1.0.tar.gz (213kB)
    100% |################################| 217kB 2.4MB/s 
    Traceback (most recent call last):
      File "<string>", line 20, in <module>
      File "/tmp/pip-build-l48p479i/spiceypy/setup.py", line 5, in <module>
        import getspice
      File "/tmp/pip-build-l48p479i/spiceypy/getspice.py", line 13, in <module>
        import six.moves.urllib as urllib
    ImportError: No module named 'six'
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):

      File "<string>", line 20, in <module>

      File "/tmp/pip-build-l48p479i/spiceypy/setup.py", line 5, in <module>

        import getspice

      File "/tmp/pip-build-l48p479i/spiceypy/getspice.py", line 13, in <module>

        import six.moves.urllib as urllib

    ImportError: No module named 'six'

    ----------------------------------------
    Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-l48p479i/spiceypy
The command "pip install -r cmd/refframes/reqs.txt" failed and exited with 1 during .
Your build has been stopped.
4

1 回答 1

1

解决方案是要求six在其他 python 要求之前安装。不知道为什么,但这有效。

这是我更新的.travis.yml文件:

language: go
go:
  - 1.7
addons:
  apt:
    sources:
      - deadsnakes # source required so it finds the package definition below
    packages:
      - python3.4
      - python3.4-dev
before_install:
  - go get github.com/axw/gocov/gocov
  - go get github.com/mattn/goveralls
  - if ! go get code.google.com/p/go.tools/cmd/cover; then go get golang.org/x/tools/cmd/cover; fi
  - sudo pip install virtualenv
  - virtualenv -p `which python3.4` .venv
  - source .venv/bin/activate
  - python -V
  - pip -V
  - pip install six
  - pip install -r cmd/refframes/reqs.txt
  - wget -O cmd/refframes/spicekernels/de430.bsp https://naif.jpl.nasa.gov/pub/naif/generic_kernels/spk/planets/de430.bsp
script:
  - python cmd/refframes/tests.py
  - go test -v -timeout=30m -covermode=count -coverprofile=coverage.out
  - $HOME/gopath/bin/goveralls -coverprofile=coverage.out -service=travis-ci
env:
  - SMD_CONFIG=./
于 2017-03-03T06:52:52.033 回答