Npm Install Python

 admin

Salam (means Hello):) I have terminal access to a VPS running centos 5.9 and default python 2.4.3 installed. I also installed python 2.7.3 via these commands: (I used make altinstall instead of m. This can be combined with the accepted answer using: npm config set python C: Python27 python.exe - I just did this and it worked fine, which means not having to do it.

  1. Npm Install Python Linux
  2. Npm Install Angular Cli

Npm install bcrypt & also python --version When i run npm install bcrypt it downloads 111 packages as where the instructors screen shows it only downloaded 1 package (the bcrypt package). I also get a completely different result than Andrews with different WARNINGS. A super-simple wrapper for NodeJS to interact programatically with the Python shell. Enables the use of Python-based tools from Node. Jamesshore changed the title from 0.6.3: npm install fails on Windows, can't find Python to 0.6.3: `npm install` fails on Windows, can't find Python Apr 17, 2014 This comment has been minimized. Show comment. Npm install bcrypt & also python --version When i run npm install bcrypt it downloads 111 packages as where the instructors screen shows it only downloaded 1 package (the bcrypt package). I also get a completely different result than Andrews with different WARNINGS.

Active1 year, 6 months ago

I have terminal access to a VPS running centos 5.9 and default python 2.4.3 installed. I also installed python 2.7.3 via these commands: (I used make altinstall instead of make install)

then I installed node.js from source via these commands:

The problem is, when I use npm install and try to install a node.js package which requires python > 2.4.3 I get this error:

how should I 'pass the --python switch to point to Python >= v2.5.0'?

Cœur
22.1k10 gold badges127 silver badges180 bronze badges
Nasser TorabzadeNasser Torabzade
2,8597 gold badges21 silver badges34 bronze badges

5 Answers

You can use --python option to npm like so:

or set it to be used always:

Npm will in turn pass this option to node-gyp when needed.

(note: I'm the one who opened an issue on Github to have this included in the docs, as there were so many questions about it ;-) )

ackack
5,7342 gold badges18 silver badges17 bronze badges

set python to python2.7 before running npm install

Linux:

Windows:

isherwood
39.2k14 gold badges88 silver badges118 bronze badges
Sandtears KirisameSandtears Kirisame

For Windows users something like this should work:

Dave L.

Npm Install Python Linux

Dave L.
6,8636 gold badges33 silver badges59 bronze badges

Ok, so you've found a solution already. Just wanted to share what has been useful to me so many times;

I have created setpy2 alias which helps me switch python.

Execute setpy2 before you run npm install. The switch stays in effect until you quit the terminal, afterwards python is set back to system default.

You can make use of this technique for any other command/tool as well.

vmxvmx
5,3763 gold badges17 silver badges20 bronze badges

for quick one time use this works,npm install --python='c:python27'

MPVMPV

Not the answer you're looking for? Browse other questions tagged pythonnode.jscentosnpm or ask your own question.

Active18 days ago

I am installing a certain NodeJS script - Caress. But i am not unable to. I am using Windows 8.1, can anyone tell me what is the problem i am facing, and why is this installation not working. There seems to be a problem with the buffertools dependency, thats far as i can think. Dont know how maybe fix this?

If i download the build from github and place it in node-modules, nothing seems to work. when i try to start, using npm start, or during implementation either.

Shaurya Chaudhuri
Shaurya ChaudhuriShaurya Chaudhuri
1,7072 gold badges18 silver badges39 bronze badges

13 Answers

As commented below you may not need to install VS on windows, check this out

UPDATED 02/2016

Some npm plugins need node-gyp to be installed.

However, node-gyp has it's own dependencies (from the github page):

UPDATED 09/2016

If you're using Windows you can now install all node-gyp dependencies with single command (NOTE: Run As Admin in Windows PowerShell):

and then install the package

UPDATED 06/2018

Delete your $HOME/.node-gyp directory and try again.

See full documentation here: node-gyp

BMW
25.6k5 gold badges61 silver badges78 bronze badges
Ilan FrumerIlan Frumer
28.9k7 gold badges60 silver badges77 bronze badges

Make sure you have all the required software to run node-gyp:

You can configure version of Visual Studio used by node-gyp via an environment variable so you can avoid having to set the --msvs_version=2012 property every time you do an npm install.

Examples:

  • set GYP_MSVS_VERSION=2012 for Visual Studio 2012
  • set GYP_MSVS_VERSION=2013e (the 'e' stands for FREE 'express edition')

For the full list see - https://github.com/joyent/node/blob/v0.10.29/tools/gyp/pylib/gyp/MSVSVersion.py#L209-294

This is still painful for Windows users of NodeJS as it assumes you have a copy of Visual Studio installed and many end users will never have this. So I'm lobbying Joyent to the encourage them to include web sockets as part of CORE node and also to possible ship a GNU gcc compiler as part of NodeJS install so we can permanently fix this problem.

Feel free to add your vote at:

Tony O'HaganTony O'Hagan
16.8k2 gold badges52 silver badges56 bronze badges

I encountered the issue with the error:

Here is what I was doing and what finally worked.

Disclaimer: I am just getting my hands into Node, Angular after many years in the Java, Linux world among others..

Environment Description: Windows 8.1 64-bit; Cygwin; cygwin bash shell

Command used that led to error: npm install -g karma

Error: gyp ERR! configure errorgyp ERR! stack Error: Can't find Python executable 'python', you can set the PYTHON env variable.

Npm Install Angular Cli

Discovery: 'which python' on bash shell clearly shows '/usr/bin/python'. Now that is annoying!

Solution: This is only applicable to those using the environment similar to what I have, i.e. using cygwin and bash shell. Hope it helps in other environments as well but keep in mind that your kettle of tea may look a little different than mine.

  1. Firstly, need to set the $PYTHON shell env variable in .bashrc using the explicit windows path to the python executable and not the unix like root path (/usr/bin) used by cygwin.
  2. Secondly, and this one took a lot of trial/error and here's the gotcha! Cygwin installs python under /usr/bin (which is really a mirror of /bin on windows) with the version, i.e. (in my system) /usr/bin/python2.7.exe and then adds a link /usr/bin/python --> python2.7.exe. The problem is that gyp cannot follow this link and keeps giving the annoying error that it cannot find python even though you can find it just fine from the shell command line.
  3. With the above background now add the following line to your .bashrc

export PYTHON='C:/cygwin64/bin/python2.7.exe (or whatever is the version on your system)'

  1. Now source your .bashrc from your home directory (on cygwin)--> 'source .bashrc'

You should be fine now and gyp will find the python executable.

I hope this helps someone stumbling on the same or similar issue.

Balthazar
31.4k10 gold badges67 silver badges95 bronze badges
AndyAndy

should be able get all node-gyp dependencies with chocolatey for Windows

tarikakyoltarikakyol

1. Install Node.js

Download installer at NodeJs website. You can download the latest V6

2. Update Npm

Npm is installed together with Node.js. So don't worry.

3. Install Anaconda

Anaconda is the leading open data science platform powered by Python. The open source version of Anaconda is a high performance distribution of Python. It can help you to manage your python dependency. You can use it to create different python environment in the futher if you want to touch with it.

Node-gyp only support >= Python 2.7 and < Python 3.0

So just install the 2.7 version

4. Install Node-gyp

You can install with npm:

$ npm install -g node-gyp

You will also need to install:

  • On Windows:

    • Option 1: Install all the required tools and configurations using Microsoft's windows-build-tools using npm install --global --production windows-build-tools from an elevated PowerShell or CMD.exe (run as Administrator).

    • Option 2: Install tools and configuration manually:

    • Visual C++ Build Environment:

      • Option 1: Install Visual C++ Build Tools using the Default Install option.
      • Option 2: Install Visual Studio 2015 (or modify an existing installation) and select Common Tools for Visual C++ during setup. This also works with the free Community and Express for Desktop editions.

      💡 [Windows Vista / 7 only] requires .NET Framework 4.5.1

    • Launch cmd, npm config set msvs_version 2015

    If the above steps didn't work for you, please visit Microsoft's Node.js Guidelines for Windows for additional tips.

Npm download

If you have multiple Python versions installed, you can identify which Python version node-gyp uses by setting the '--python' variable:

$ node-gyp --python C:/Anaconda2/python.exe

If node-gyp is called by way of npmand you have multiple versions of Python installed, then you can set npm's 'python' config key to the appropriate value:

$ npm config set python C:/Anaconda2/python.exe

Future update for Node.js and npm

Download installer from their official website and direct install it. The installer will automatic help you to remove old files.

Does the windows printer driver (see above posts) for the HP 1320 allow 1200dpi printing. I have the printer running with a driver downloaded from HP (I think it was), but it will only let the printer print up to 600dpi and not the 1200 dpi it was capable of under XP. I have a HP 1320 connected to my Win7 64 bit PC. Thanking you in advance.about the resolution: I don't know if you get better res with MS drivers. Hp lj 1320 driver windows 7 32 bit. Also how best to uninstall the current printer driver if i decide to try the windows driver?

npm update npm

Future update for Python

conda update --all

YoongKang LimYoongKang Lim

For Cygwin users:

The python issue with using npm on an out-of-the-box Cygwin installation, is that node-gyp is giving a misleading error due to incomplete checking in the ./npm/node_modules/node-gyp/lib/configure.js code.

It's due to how Cygwin treats symbolic links. It doesn't do that properly in an out-of-the box installation. So the error messages from the above code become misleading, as it complains about the PYTHON path and not the existence of python.exe (or link of) file itself.

There are (at least) 2 ways to resolve this.

  1. Installing the Cygwin package cygutils-extra and use winln.
  2. Use native Windows CMD in Admin mode.

For (1) you can create a proper symlink from within Cygwin shell by doing these steps:

(Also assuming you are running the Cygwin shell as Admin.)Using apt-cyg is recommended and can be found in various forms on github.

For (2) the resolution for out-of-the-box Cygwin users is this:

The result should look like this:

emigenixemigenix

For windows

Check python path in system variable.npm plugins need node-gyp to be installed.

open command prompt with admin rights, and run following command.

npm install --global --production windows-build-tools

npm install --global node-gyp

Mahesh GudadariMahesh Gudadari

gyp ERR! configure error gyp ERR! stack Error: Can't find Python executable 'python', you can set the PYT HON env variable.

This means the Python env. variable should point to the executable python file, in my case:SET PYTHON=C:work_envPython27python.exe

Y. AliakseiY. Aliaksei
OrrOrr
3,3721 gold badge21 silver badges28 bronze badges

I was installing appium by npm install -g appium and getting the same error on Windows 10.

Below command worked for me:

hemantohemanto

The question is already answered but these were not working in my case which is alpine Linux based OS so maybe this helps someone else.

I was also getting same error

So fix by single line just add this if you are working in Dockerfile or install it in OS

in ubuntu

Note: Node version:8

AdiiiAdiii
9,8511 gold badge38 silver badges45 bronze badges
brajesh jaishwalbrajesh jaishwal

Fixed with downgrading Node from v12.8.1 to v11.15.0 and everything installed successfully

MaksymMaksym
15.2k5 gold badges21 silver badges27 bronze badges

Not the answer you're looking for? Browse other questions tagged node.jsnpm or ask your own question.