如何在没有sudo的travis中安装python包?

时间:2017-01-05 03:36:14

标签: python unix github travis-ci

在我的travis脚本中禁用了sudo,因此我无法执行“pip install'安装python包。有没有其他方法可以安装没有sudo的python包?

使用以下命令仍然失败

install:
  - pip install -U pip
  - pip install <whatever>



$ pip install -U pip

You are using pip version 6.0.8, however version 9.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
Collecting pip from https://pypi.python.org/packages/b6/ac/7015eb97dc749283ffdec1c3a88ddb8ae03b8fad0f0e611408f196358da3/pip-9.0.1-py2.py3-none-any.whl#md5=297dbd16ef53bcef0447d245815f5144
  Downloading pip-9.0.1-py2.py3-none-any.whl (1.3MB)
    100% |################################| 1.3MB 457kB/s 
Installing collected packages: pip
  Found existing installation: pip 6.0.8
    Uninstalling pip-6.0.8:
      Exception:
      Traceback (most recent call last):
        File "/usr/local/lib/python2.7/dist-packages/pip-6.0.8-py2.7.egg/pip/basecommand.py", line 232, in main
          status = self.run(options, args)
        File "/usr/local/lib/python2.7/dist-packages/pip-6.0.8-py2.7.egg/pip/commands/install.py", line 347, in run
          root=options.root_path,
        File "/usr/local/lib/python2.7/dist-packages/pip-6.0.8-py2.7.egg/pip/req/req_set.py", line 543, in install
          requirement.uninstall(auto_confirm=True)
        File "/usr/local/lib/python2.7/dist-packages/pip-6.0.8-py2.7.egg/pip/req/req_install.py", line 667, in uninstall
          paths_to_remove.remove(auto_confirm)
        File "/usr/local/lib/python2.7/dist-packages/pip-6.0.8-py2.7.egg/pip/req/req_uninstall.py", line 126, in remove
          renames(path, new_path)
        File "/usr/local/lib/python2.7/dist-packages/pip-6.0.8-py2.7.egg/pip/utils/__init__.py", line 316, in renames
          shutil.move(old, new)
        File "/usr/lib/python2.7/shutil.py", line 297, in move
          rmtree(src)
        File "/usr/lib/python2.7/shutil.py", line 245, in rmtree
          rmtree(fullname, ignore_errors, onerror)
        File "/usr/lib/python2.7/shutil.py", line 250, in rmtree
          onerror(os.remove, fullname, sys.exc_info())
        File "/usr/lib/python2.7/shutil.py", line 248, in rmtree
          os.remove(fullname)
      OSError: [Errno 13] Permission denied: '/usr/local/lib/python2.7/dist-packages/pip-6.0.8-py2.7.egg/EGG-INFO/PKG-INFO'

2 个答案:

答案 0 :(得分:3)

根据official doc

  默认情况下,

sudo: false为2015或更高版本启用的存储库

您可以在pip install中的install:属性后面写.travis.yml,它应该支持pip。

language: python
python:
  - "2.7"
install:
  - pip install --user -U pip
  - pip install --user <whatever>

答案 1 :(得分:0)

sudo:标记现已在Travis CI中完全弃用。 sudo 命令始终可用。