0

I'm trying to upgrade six on my mac for TensorFlow, and I did:

sudo pip install --ignore-installed six

And I get:

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

The point is that it ends with successfully installed. But when I go into ipython interpreter to do:

import six
six.__version__

I still see 1.4.1. What is the solution?

xiaolingxiao
  • 4,793
  • 5
  • 41
  • 88
  • Your `IPython` is probably set to use a different Python executable than the executable `pip` uses. Thus `pip` installs for one Python version, while `IPython` runs with another Python version. Have a look at the first line of both your `pip` script and your `ipython` script, and see to which Python executables they point. –  Jan 16 '17 at 00:53
  • ok you're right. check pip.__version__ in just `python` gets me 1.10.0 and TensorFlow work as expected. How do I make sure iPython is calling the appropriate six version? where is this ipython script? – xiaolingxiao Jan 16 '17 at 00:56
  • You can probably find the `IPython` script by typing `which ipython` or `type ipython`. Then it'll depend on whether you'd want to use the Python executable that IPython is using (in that cause, install `six` for that Python), or you'd want to change the first line in the `ipython` script. Be aware though, that then either modules may not be found, or IPython itself may not be found. –  Jan 16 '17 at 03:44
  • If you have a recent version of IPython, you could also try and run `python -m jupyter console` and see if that works. –  Jan 16 '17 at 03:45
  • 1
    Important note: it does appear you have two versions of Python running on your system. One has `six` installed at version 1.10.0 (and TensorFlow), the other has IPython installed and `six` at version 1.4.1. Plus there's that bunch of warnings during your installation, so things are a bit messy (you've probably pip-installed things without sudo at some point, and then later again with sudo). Be aware of that. –  Jan 16 '17 at 03:49

1 Answers1

0

Use -U or --upgrade to upgrade the package:

sudo pip install --upgrade six

Option 1:

Within ipython:

import pip

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

install('six')

Option 2:

Within ipython:

import sys
sys.path 

Then see where the packages for ipython are installed. It should look something like:

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

Do the same in your terminal python to find where you installed the newer six package. Then copy that newer six package into the ipython site-packages directory (move the six-1.4.1 package to another directory first just in case).

After that, register the new package into 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) 

Then you can

import six

ipython should keep track of the newer six package on restart.

ooknosi
  • 374
  • 1
  • 2
  • 8