简体   繁体   中英

How to install python with git bash and npm in windows

currently using windows 7 machine to check cross browser testing. When doing npm install , it says node-gyp rebuild , then it looks for python executable.

I am using git bash and set

  • PATH=$PATH:/c/my_account/.../anaconda3/python.exe
  • PYTHON=$PATH:/c/my_account/../anaconda3/python.exe
  • PYTHONPATH=$PATH:/c/my_account/../anaconda3/python.exe in .bashrc

With this setup, I still have same error.

What is the proper way to install python in windows machine, so git bash and npm is aware of it?

It is a corporate machine, so technique like npm install -g windows-build-tools won't work for me.

*PATH variables are for listing paths (ie directories or folders). As such, you should remove "python.exe" from the end of each of these lines.

The PATH variable should be a colon-separated list of any directories that contain executables you would like to run without having to specify a relative or absolute path. To the best of my knowledge, PYTHON is not used by anything and perhaps need not be defined. You (very probably) do NOT want to include $PATH when defining PYTHONPATH. It should be just the location of your Python installation.

If you put these in .bashrc , you also want to export them so they are defined in your environment after .bashrc finishes execution.

export PATH=/c/my_account/.../anaconda3:$PATH
export PYTHONPATH=/c/my_account/.../anaconda3

As a side note, you might try running which python or which python.exe . If that command points to the correct version of Python, your path variables are probably set up correctly.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM