how to start mongodb daemon in python

mongodb, python, subprocess

Solution

Split `'--dbpath C:\\dropbox\\projects\\mongodb'`, it should be `'--dbpath', 'C:\\dropbox\\projects\\mongodb'`. There are two independent command line parameters, not one, they are grouped logically by mongodb args parsing code. And it should be `--dbpath`, not `----dbpath`, at least on Linux it is.

UPD: Your original code executes `mongod` like this:

C:\\mongodb\\bin\\mongod "----dbpath C:\\dropbox\\projects\\mongodb"

Problem

how can I start the mongodb daemon in python? I have the following script ``` import subprocess subprocess.Popen(['C:\\mongodb\\bin\\mongod', '----dbpath C:\\dropbox\\projects\\mongodb']) ``` and I get this error: error command line: unknown option --dbpath C:\dropbox\projects\mongodb The mongo database is already created in C:\dropbox\projects\mongodb\ I can move the mongo database to c:\ and not specify the '--dbpath' and it works fine. I can also run mongod from the windows shell with the specified '--dbpath' and it runs fine. For some reason when I try to run it from python it does not like the '--dbpath' argument being passed to it. any ideas?

Original source