Не удается обновить six на mac os X Yosemite

Я пытаюсь обновить six на моем mac для TensorFlow, и я сделал:

sudo pip install --ignore-installed six

И я получаю:

The directory '/Users/lingxiao/Library/Caches/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 '/Users/lingxiao/Library/Caches/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 six

/Library/Python/2.7/site-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:318: SNIMissingWarning: An HTTPS request has been made, but the SNI (Subject Name Indication) extension to TLS is not available on this platform. This may cause the server to present an incorrect TLS certificate, which can cause validation failures. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/security.html#snimissingwarning.
  SNIMissingWarning
/Library/Python/2.7/site-

packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:122: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/security.html#insecureplatformwarning.
  InsecurePlatformWarning
  Downloading six-1.10.0-py2.py3-none-any.whl
Installing collected packages: six
Successfully installed six-1.10.0

Дело в том, что он заканчивается успешно установлен. Но когда я иду в IPython переводчик делать:

import six
six.__version__

Я все еще вижу 1.4.1. Какое решение?

1 ответ

  1. Используйте -U или —upgrade для обновления пакета:

    sudo pip install --upgrade six
    

    Вариант 1:

    В пределах ipython:

    import pip
    
    def install(package):
       pip.main(['install', package])
    
    install('six')
    

    Вариант 2:

    В пределах ipython:

    import sys
    sys.path 
    

    Затем посмотрите, где установлены пакеты для ipython. Это должно выглядеть примерно так:

    '/Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/six-1.4.1 blah blah'
    

    Сделайте то же самое в вашем терминале python, чтобы найти, где вы установили новый пакет six. Затем скопируйте этот новый пакет six в каталог ipython site-packages (на всякий случай сначала переместите пакет six-1.4.1 в другой каталог).

    После этого зарегистрируйте новый пакет в ipython:

    # use your six located in your ipython path
    six_path = '/Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/six-1.10.0 blahblah'
    sys.path.append(six_path) 
    

    Тогда вы можете

    import six
    

    ipython должен отслеживать новый пакет six при перезапуске.