V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
woshilibai
V2EX  ›  Python

关于在腾讯云主机上使用 pip 安装的问题

  •  
  •   woshilibai · 2018-03-08 16:54:51 +08:00 · 2754 次点击
    这是一个创建于 2487 天前的主题,其中的信息可能已经有所发展或是发生改变。

    就是前两天腾讯活动买的主机,操作系统是 Ubuntu。

    现在要在主机上安装 python 包,pip3 使用 apt 工具安装成功了,但是使用 pip 却总是不成功?

    运行:sudo pip3 install virtualenv

    报错:TypeError: unsupported operand type(s) for -=: 'Retry' and 'int'

    ubuntu@VM-0-3-ubuntu:~$ sudo pip3 install virtualenv
    The directory '/home/ubuntu/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
    The directory '/home/ubuntu/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
    Collecting virtualenv
    Exception:
    Traceback (most recent call last):
      File "/usr/share/python-wheels/urllib3-1.13.1-py2.py3-none-any.whl/urllib3/connection.py", line 137, in _new_conn
        (self.host, self.port), self.timeout, **extra_kw)
      File "/usr/share/python-wheels/urllib3-1.13.1-py2.py3-none-any.whl/urllib3/util/connection.py", line 91, in create_connection
        raise err
      File "/usr/share/python-wheels/urllib3-1.13.1-py2.py3-none-any.whl/urllib3/util/connection.py", line 81, in create_connection
        sock.connect(sa)
    OSError: [Errno 99] Cannot assign requested address
    
    During handling of the above exception, another exception occurred:
    
    Traceback (most recent call last):
      File "/usr/share/python-wheels/urllib3-1.13.1-py2.py3-none-any.whl/urllib3/connectionpool.py", line 560, in urlopen
        body=body, headers=headers)
      File "/usr/share/python-wheels/urllib3-1.13.1-py2.py3-none-any.whl/urllib3/connectionpool.py", line 346, in _make_request
        self._validate_conn(conn)
      File "/usr/share/python-wheels/urllib3-1.13.1-py2.py3-none-any.whl/urllib3/connectionpool.py", line 787, in _validate_conn
        conn.connect()
      File "/usr/share/python-wheels/urllib3-1.13.1-py2.py3-none-any.whl/urllib3/connection.py", line 217, in connect
        conn = self._new_conn()
      File "/usr/share/python-wheels/urllib3-1.13.1-py2.py3-none-any.whl/urllib3/connection.py", line 146, in _new_conn
        self, "Failed to establish a new connection: %s" % e)
    requests.packages.urllib3.exceptions.NewConnectionError: <requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x7f6fcc3c6fd0>: Failed to establish a new connection: [Errno 99] Cannot assign requested address
    
    During handling of the above exception, another exception occurred:
    
    Traceback (most recent call last):
      File "/usr/lib/python3/dist-packages/pip/basecommand.py", line 209, in main
        status = self.run(options, args)
      File "/usr/lib/python3/dist-packages/pip/commands/install.py", line 317, in run
        requirement_set.prepare_files(finder)
      File "/usr/lib/python3/dist-packages/pip/req/req_set.py", line 360, in prepare_files
        ignore_dependencies=self.ignore_dependencies))
      File "/usr/lib/python3/dist-packages/pip/req/req_set.py", line 512, in _prepare_file
        finder, self.upgrade, require_hashes)
      File "/usr/lib/python3/dist-packages/pip/req/req_install.py", line 273, in populate_link
        self.link = finder.find_requirement(self, upgrade)
      File "/usr/lib/python3/dist-packages/pip/index.py", line 442, in find_requirement
        all_candidates = self.find_all_candidates(req.name)
      File "/usr/lib/python3/dist-packages/pip/index.py", line 400, in find_all_candidates
        for page in self._get_pages(url_locations, project_name):
      File "/usr/lib/python3/dist-packages/pip/index.py", line 545, in _get_pages
        page = self._get_page(location)
      File "/usr/lib/python3/dist-packages/pip/index.py", line 648, in _get_page
        return HTMLPage.get_page(link, session=self.session)
      File "/usr/lib/python3/dist-packages/pip/index.py", line 757, in get_page
        "Cache-Control": "max-age=600",
      File "/usr/share/python-wheels/requests-2.9.1-py2.py3-none-any.whl/requests/sessions.py", line 480, in get
        return self.request('GET', url, **kwargs)
      File "/usr/lib/python3/dist-packages/pip/download.py", line 378, in request
        return super(PipSession, self).request(method, url, *args, **kwargs)
      File "/usr/share/python-wheels/requests-2.9.1-py2.py3-none-any.whl/requests/sessions.py", line 468, in request
        resp = self.send(prep, **send_kwargs)
      File "/usr/share/python-wheels/requests-2.9.1-py2.py3-none-any.whl/requests/sessions.py", line 576, in send
        r = adapter.send(request, **kwargs)
      File "/usr/share/python-wheels/CacheControl-0.11.5-py2.py3-none-any.whl/cachecontrol/adapter.py", line 46, in send
        resp = super(CacheControlAdapter, self).send(request, **kw)
      File "/usr/share/python-wheels/requests-2.9.1-py2.py3-none-any.whl/requests/adapters.py", line 376, in send
        timeout=timeout
      File "/usr/share/python-wheels/urllib3-1.13.1-py2.py3-none-any.whl/urllib3/connectionpool.py", line 610, in urlopen
        _stacktrace=sys.exc_info()[2])
      File "/usr/share/python-wheels/urllib3-1.13.1-py2.py3-none-any.whl/urllib3/util/retry.py", line 228, in increment
        total -= 1
    TypeError: unsupported operand type(s) for -=: 'Retry' and 'int'
    
    
    3 条回复    2018-03-08 20:46:40 +08:00
    woshilibai
        1
    woshilibai  
    OP
       2018-03-08 20:41:45 +08:00 via Android
    已解决,是主机没配置好。
    yech1990
        2
    yech1990  
       2018-03-08 20:44:41 +08:00
    用 pip install -i http://mirrors.tencentyun.com/pypi/simple <some-package> 速度提示明显
    woshilibai
        3
    woshilibai  
    OP
       2018-03-08 20:46:40 +08:00 via Android
    腾讯的源还真没用过,用过豆瓣源,清华源,不过一般不用
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   2702 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 23ms · UTC 14:39 · PVG 22:39 · LAX 06:39 · JFK 09:39
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.