Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

How to install npm package from python script?

When I use subprocess.Popen(["node", "app.js"]) it is OK.
When I use subprocess.Popen(["npm", "install", "open"]) it is throwing an error.

Sorry, but Google and DuckDuckGo are not my friends today(

The main problem — automatic local installation required packages for my small utility, because global packages are not working in windows.

PS. I'm have to ask this question because I’m trying to develop plugin for Sublime Text 2.

This is the error in Sublime python console:

Reloading plugin …\stsync.py
Traceback (most recent call last):
  File ".\sublime_plugin.py", line 103, in create_application_commands
    cmds.append(class_())
  File ".\stsync.py", line 16, in __init__
  File ".\subprocess.py", line 633, in __init__
  File ".\subprocess.py", line 842, in _execute_child
WindowsError: [Error 2] 

line 16: subprocess.Popen(["node", "npm", "install", "open"])


If I will change 16 line to subprocess.Popen(["node", "npm", "install", "open"]) then python script will successfully invoke nodejs terminal, but then nodejs terminal will fail with error:
cannot find npm module
nodejs error

share|improve this question
    
What error? Does typing npm into a command window work? –  wdavo Feb 4 '13 at 5:16
    
@wdavo in terminal node and npm are working ok –  Vladimir Starkov Feb 4 '13 at 5:19
    
@wdavo I added some context in question –  Vladimir Starkov Feb 4 '13 at 5:24
    
I once created this helper github.com/miohtama/vvv/blob/master/vvv/sysdeps.py#L221 if it's any useful for you –  Mikko Ohtamaa Feb 4 '13 at 22:01

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.