Some Python scripts use the
webbrowser module to launch a browser for a given URL. If you're on a headless server, it'll launch a text-based browser (eg. in Debian it's
w3m
) which might not be desired (many websites are less than usable in text-based browsers and the launch of such an URL in a text-based browser is more an annoyance than help). You can easily avoid this behaviour.
The documentation of the
webbrowser
module says that one can override the module's browser detection/selection algorithm by setting the
BROWSER
environment variable. Thus the solution is fairly trivial:
BROWSER=/bin/true my_python_script.py
Eg. scripts for various online services (Google+, Facebook, Flickr, etc.) need authorization and try to open an URL. These scripts print the URL to the terminal and open the URL via
webbrowser
at the same time. Since you can easily copy&paste the URL from your terminal into a browser, the text-based browser part is unnecessary.
Recent comments
2 years 26 weeks ago
3 years 47 weeks ago
3 years 47 weeks ago
3 years 49 weeks ago
3 years 50 weeks ago
4 years 5 weeks ago
4 years 5 weeks ago
4 years 5 weeks ago
4 years 5 weeks ago
4 years 5 weeks ago