问题
So typically I am too stubborn to use forum sites myself (call me proud), but this has been driving me absolutely mad.
My goal is simply to start Chrome on a server machine, through that server's python WSGI script. I am aware of the bug that prevents Python from using Popen under WSGI, but I've figured out what seemed like a workable (albeit somewhat hack-y) solution: instead of calling Popen with the actual command, I created a .bat and called the bat through Popen with the shell argument set to True
. This actually works for just about everything other than what I needed it to; i.e., calling start iexplore
worked, start firefox
worked, even notepad
and mspaint
, but the only thing that didn't work, was calling start chrome
. I've even tried a few command-line arguments, like start chrome --single-process
, but to no avial.
It's like Windows just hates Chrome. I would greatly appreciate any help, as I've been pulling my hair out over this for the last 48 hours.
tl;dr: Chrome won't start from a batch script called using subprocess.Popen
, but everything else will.
Relevant Technical Stuff
Python script [excerpt]:
import subprocess
command="<path>\\start-browser.bat" # Absolute path to Batch file
subprocess.Popen(command,shell=True)
Batch file:
start /d "C:\Documents and Settings\<Me>\Local Settings\Application Data\Google\Chrome\Application" chrome.exe
System:
- Windows XP sp3, 32-bit
- Python 2.7
- Apache 2.2
回答1:
I haven't tried this in your case, but I know a lot of Chrome's oddities come about because it is installed per user. Have you tried logging in as Administrator and installing Chrome for all users?
来源:https://stackoverflow.com/questions/10809944/trying-to-start-chrome-from-wsgi-python-admittedly-quick-and-dirty-win-xp-x