1

I am developing a plugin for a multi-platform Python program (Deluge). My plugin needs to import some modules which aren't available by default (in my case, the requests module).

On Linux, everything works flawlessly assuming the required modules are installed beforehand (e.g. via pip).

On Windows, the program makes use of python27.dll which comes as part of the installer, so importing modules - even those available on the local Python installation (verified via interpreter) - yields an import error.

I've seen the answers to this question, but I'd like to know if there is a proper way of adding module search paths for Python on Windows specifically. Is it safe to assume C:\Python27\Lib\site-packages will point me to the local Python installation's modules?

EDIT: Is there a different method I could incorporate for using "external" modules? Could I perhaps package other modules into my final .egg file? Not just plain Python, but more sophisticated modules like requests which need to be properly built and may even rely on other modules.

Community
  • 1
  • 1
Charles
  • 157
  • 1
  • 10
  • Print `sys.path` to see where you can add modules. – Eryk Sun Jun 08 '16 at 12:48
  • Printing `sys.path` from the context of the plugin outputs the standalone Python's `sys.path`, which is mostly files/folders under `C:\Program Files (x86)\Deluge`, mainly `.egg` files. If you meant to print the local Python installation's `sys.path`, that would be a good way to locate the `site-packages` folder, but I would need to call the locally installed Python to get its' path locations... Wouldn't that be "messy"? – Charles Jun 08 '16 at 19:32
  • No, just look at `sys.path` under Deluge. Is the main application directory or a subdirectory in `sys.path`? Is a zipped library? – Eryk Sun Jun 08 '16 at 22:49
  • `C:\Program Files (x86)\Deluge`, and the other paths are `library.zip`, `deluge-1.3.12-py2.7.egg`, and all of the other plugins' `.egg` files under the main Deluge `.egg`. Do you mean that I should somehow add the `requests` module to the Deluge directory? – Charles Jun 09 '16 at 08:45

0 Answers0