简体   繁体   中英

How to install python packages in travis without sudo?

sudo is disabled in my travis script, so I can not execute 'pip install' to install python packages. Is there any other way that I can install python packages without sudo ?

It still fails using the following command

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'

According to official doc

sudo: false by default for repositories enabled in 2015 or later

You can write pip install after attribute install: in .travis.yml , it should support pip.

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

The sudo: tag is now fully deprecated in Travis CI. The sudo command is always available.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM