View Single Post
Old 11-09-2015, 07:59 PM   #37
DiapDealer
Grand Sorcerer
DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.
 
DiapDealer's Avatar
 
Posts: 27,552
Karma: 193191846
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
Sigil's bundled Python has no bs4 module. It has a modified version of BeautifulSoup called sigil_bs4 that's available to all plugins.

Developers who want plugins which have a bs4 dependency to work with Sigil's bundled python AND an external python installation will probably want to do something like:
Code:
try:
  from sigil_bs4 import BeautifulSoup
except ImportError:
  from bs4 import BeautifulSoup
This will have the advantage of still being able to work if and when Sigil's modified bs4 module ever becomes unnecessary in the future.

Just using:
Code:
from sigil_bs4 import BeautifulSoup
will probably work too, since the sigil_bs4 module is available to any external python installations (via the launcher framework), but has the disadvantage of possibly not working with earlier versions of Sigil, and potentially not working with future versions, if the special sigil_bs4 module ever becomes unnecessary.

Even if you have no plans to support external python interpreters with your plugin, it will still probably be a good idea to incorporate the try/except technique with (sigil_)bs4 for future-proofing. bs4 is currently the only "non-stock" python module that Sigil uses. If the constraints that force us to use it ever go away, we'd love to do away with it and replace it with the stock version. This technique will ensure your plugin's continued functionality in the event that happens.

Quote:
Originally Posted by exaltedwombat View Post
What's going wrong? I got this working once!
If you had it working once, I assume it's because you have a working external installation of Python with bs4 already installed. If that's the case, just uncheck "Use Bundled Python" and setup your external Python interpreter(s) in Manage Plugins.

Last edited by DiapDealer; 11-09-2015 at 08:36 PM.
DiapDealer is offline   Reply With Quote