2

I'm new to MAC (OSX version is High Sierra 10.13.3). I installed python 3.6.5 with the installer from python.org and I tried doing it with brew too by running brew install python. Now, I'm trying to run sudo npm install in a Angular project and I get the following errors:

gyp verb check python checking for Python executable "/path/to/python3/python" in the PATH
gyp verb `which` failed Error: not found: /path/to/python3/python
gyp ERR! stack Error: Can't find Python executable "/path/to/python3/python", you can set the PYTHON env variable.

I have tried all the answers in here :

python location on mac osx

Can't find Python executable "python"

Inside of my projects folder I do the following:

when I type 'which python' I get:

/usr/local/opt/python/libexec/bin/python

When I type 'which python3.6.5' I get:

/Library/Frameworks/Python.framework/Versions/3.6/bin/python3.6
Patricio Vargas
  • 5,236
  • 11
  • 49
  • 100
  • 2
    First, you've installed at least two extra Pythons on top of the one Apple preinstalled, instead of just one. That will just make things even more confusing. Uninstall one of them. – abarnert Jun 18 '18 at 20:41
  • 2
    Second, have you actually put the literal string `/path/to/python3` or `/path/to/python3/python` somewhere? If so, you were supposed to substitute that with the actual path to python3, like `/Library/Frameworks/Python.framework/Versions/3.6/bin/` or `/Library/Frameworks/Python.framework/Versions/3.6/bin/python3.6`. – abarnert Jun 18 '18 at 20:44
  • @abarnert Correct. I install the lastest version because I know MAC comes with a default one but when I was running npm install it has saying that I need python. With that being said, I see a executable in the launcer in the mac, but when I drag it to the trash can, it doesn't get uninstall. any safe way to do so? – Patricio Vargas Jun 18 '18 at 20:44
  • 2
    First, you cannot uninstall the Python that came with macOS, and you do not want to. You can uninstall either of the two Python 3.6 versions, however. The simplest way is `brew unlink python`, which should remove the Homebrew one, leaving the python.org one. – abarnert Jun 18 '18 at 20:47
  • @abarnert related to your second comment. I probably did. I have tried so many things for the past 3 hours. How can i reset the literal string? Also when i do brew doctor I notice this related to your first comment. Having additional scripts in your path can confuse software installed via Homebrew We found the following "config" scripts: /Library/Frameworks/Python.framework/Versions/3.6/bin/python3.6m-config /Library/Frameworks/Python.framework/Versions/3.6/bin/python3-config /Library/Frameworks/Python.framework/Versions/3.6/bin/python3.6-config` – Patricio Vargas Jun 18 '18 at 20:49
  • 2
    Meanwhile, if you're using `gyp`, AFAIK that's a dead project which doesn't support Python 3 and never will, which means installing Python 3.6 isn't going to help. Either use Apple's Python 2.7, or install another Python 2.7 instead. IIRC, for the former, it should be as simple as `npm install --python=python2.7`. But if you search for help on that, instead of help on Python installations that you didn't actually need to do, you'll probably find better information. – abarnert Jun 18 '18 at 20:50
  • I have uninstall python from brew. I apologize for installing a python when I didnt need it. I'm new to macs. I did npm install --python=python2.7` and I got `gyp verb check python checking for Python executable "python2.7" in the PATH gyp verb `which` succeeded python2.7 /usr/local/bin/python2.7` is there a way to set the PATH that way I can just do `npm install?` – Patricio Vargas Jun 18 '18 at 20:55
  • You shouldn't need to set the `PATH`; if `python` runs the builtin Python 2.7 (as it did before you installed anything), it should just work. I believe `gyp` tries `python2` first, and Apple doesn't install anything with that name. That shouldn't be necessary, but if it is, you can make a symlink. Something like: `sudo ln -s /usr/bin/python2.7 /usr/local/bin/python2`. But, again, it shouldn't be necessary in the first place. – abarnert Jun 18 '18 at 21:00
  • @abarnert YOU are right in all these. I even ran that command and it was telling me that it already exist. I got the solution for my problem by deleting the repo and running npm install and it worked. Thanks for your help – Patricio Vargas Jun 18 '18 at 21:22

2 Answers2

5

For me it was all happening because of nodejs version.

Node version 16+ does not support "node-sass": "^4.14.1", so I have to install nvm and downgrade the nodesjs in macbook as follows

  • Before installing nvm, run this in terminal: touch ~/.bash_profile

  • After, run this in terminal: curl -o-
    https://raw.githubusercontent.com/creationix/nvm/v0.33.1/install.sh | bash

  • Important... - DO NOT forget to Restart your terminal OR use command source ~/.nvm/nvm.sh (this will refresh the available commands in
    your system path).

  • In the terminal, use command nvm --version and you should see the
    version

  • bash nvm install 14.17.0

1

It looks like my node_modules folder was screwed up. I deleted the repo and cloned again and it worked.

Patricio Vargas
  • 5,236
  • 11
  • 49
  • 100