nativescript-cli: WARNING: The Python 'six' package not found.

From @obiwankenoobi on April 18, 2018 11:52

after installing NativeScript on my macos using ruby -e "$(curl -fsSL https://www.nativescript.org/setup/mac)" I ran into error while typing tns doctor which tells me WARNING: The Python 'six' package not found. and when I trying to install six by pip install six I get the message : Requirement already satisfied: six in /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python (1.4.1) so there is six installed but yet it wont let me move on because of it

Copied from original issue: NativeScript/NativeScript#5699

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 2
  • Comments: 36 (12 by maintainers)

Most upvoted comments

Just reproduced the issue on brand new macOS High Sierra.

Here is what happens: tns doctor fails because six is not found. This happens because python -c "import six" fails. On the other side pip install six says Requirement already satisfied.

Here is how I was able to workaround it:

sudo pip install --upgrade pip
pip install --user --upgrade matplotlib
pip install six

@obiwankenoobi what is your OS perhaps El Capitan? If so try this solution

pip install --ignore-installed six

I was having the same issue as @phenric, ended up installing python through brew and symlinking to the path given by the brew install as well.

For me the whole process looked like this:

  • brew install python
  • look for line Python has been installed as in install script output
  • sudo ln -s -f path from above line /usr/local/bin/python
  • python(now pointing to brew installed python through sym link) -m pip install --upgrade pip
  • python -m pip install six

Hope this helps someone, spent way too much time on just this issue.

@phenric what are the symptoms, errors?

When you run any ns command it simply uses your current shell + environment (nothing funky going on there)… But simply doing an alias will not work because XCode on the other hand does not load user shell profiles - that’s why we recommend doing a symlink into /usr/local/bin which is a path that the whole system uses including XCode.

Now there is an issue with the system installed python I noticed, it prompts to install additional command line tools, but then does nothing. I shared a workaround a few times on discord (and one of the github discussions) which should work:

brew install python
sudo ln -s -f $(which python3) /usr/local/bin/python

# -s - symbolic
# -f - force - overrides existing links if necessary

This may not work if somehow the freshly installed python isn’t the default (brew will usually print a warning/instructions if that’s the case), but essentially you need to create a symlink in /usr/local/bin that points to the brew installed python3.

I had the same issue. I solved it with listing modules

(Python 2.7.15) pip2 list and (Python 3.6.5) pip3 list

tns uses pip2 in my case (Mac 10.13.6)

I did pip2 install six

after that

tns doctor fund six package

@rigor789 Thank you for the time you gave to the community. I fix the issue by using HomeBrew’s python3 instead of the default one. I symlinked as you explain and removed the aliases I previously wrote.

I had to run the following to fix the issue

brew uninstall --force --ignore-dependencies python@2
brew uninstall --force --ignore-dependencies python
brew install python
brew install python@2

Also works on 10.13.6 plus I had to first install pip. sudo easy_install pip

then, only pip install --user --upgrade matplotlib pip install six

The first command failed on ownership and lack of cache setting.

Without this, Sidekick failed to instantiate it’s user interface.

The solution proposed by dtopuzov fixes the issue on MacOS High Sierra 10.13.4

I have run a few commands, and after run this “python -m pip install --upgrade six”, I tried again, and it works. Maybe you can try run this first to see if if fixed or not.

After many trials and errors, not sure if it will fix again but, I used the following command:

sudo pip install --ignore-installed  --upgrade six

I removed the sudo to check the version. Latest is 1.11.0.

Just guesting, but it might be related two more than one python available on the machine.

six might be available for one of them, but may be CLI check the other python availalbe on the machine.

@obiwankenoobi If I’m in this cause this is what I’ll try:

  1. Run which python, the output should be some path, for example /usr/local/bin/python
  2. Run ls -la on the path to check where it points (run ls -la /usr/local/bin/python in my case)
  3. Then find pip of this python installation (it should be in the same bin folder where python executable is located) and run <path-to-pip>/pip install six.

Looks like tns is trying to run python as sh. Open your terminal and run sh, here I was unable to run python or pip.

For me it started working after I aliased python and pip to python3 and pip3, I also had to run @rigor789’s symlink stuff for both python and pip.

Not quite sure why the system installed python refuses to work when being symlinked - I’m guessing they are doing some funky invocation checking on boot…

Hi @rigor789 Thank you for your time. I don’t understand why it used to work before ns clean. I also have a default python3 installed here -> /usr/bin/python3.

I use the command provided in the guide sudo ln -s $(which python3) /usr/local/bin/python and it sill ask me for a fresh new installation with XCode as you mention. I’ll try with brew and let you know if it works but if you could explain me the reason I’d highly appreciate. Again thx your answer.

Solution for Mac OS Catalina. Set your PYTHONPATH environment variable to /Library/Python/2.7/site-packages.

You can do this for your current termincal instance with: export PYTHONPATH=/Library/Python/2.7/site-packages

OR add it permanently to your ~/.bash_profile file. (note you will need to restart your terminal window after doing this.)

See: https://stackoverflow.com/questions/29485741/unable-to-upgrade-python-six-package-in-mac-osx-10-10-2

@obiwankenoobi,

Can you try to execute pip install -U six?