Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #8823 > unrolled thread

Re: imp.find_module don't found my module but standard import statement can import this module… why ?

Started byEric Snow <ericsnowcurrently@gmail.com>
First post2011-07-05 07:44 -0600
Last post2011-07-05 07:44 -0600
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: imp.find_module don't found my module but standard import statement can import this module… why ? Eric Snow <ericsnowcurrently@gmail.com> - 2011-07-05 07:44 -0600

#8823 — Re: imp.find_module don't found my module but standard import statement can import this module… why ?

FromEric Snow <ericsnowcurrently@gmail.com>
Date2011-07-05 07:44 -0600
SubjectRe: imp.find_module don't found my module but standard import statement can import this module… why ?
Message-ID<mailman.626.1309873442.1164.python-list@python.org>
On Tue, Jul 5, 2011 at 1:36 AM, Stéphane Klein <stephane@harobed.org> wrote:
> Hi,
>
> I would like import some module dynamically.
>

To import a module dynamically, you can use the built-in __import__ function:

  module = __import__("js")

Even better, use importlib's import_module, which is available in
2.7/3.2.  A backport is available on PyPI.

  module = importlib.import_module("js")

-eric

> First, I install "js.jquery"
>
> $ pip install js.jquery
>
> Here, I would like import "js" module.
>
>>>> import imp
>>>> imp.find_module("js")
> Traceback (most recent call last):
>  File "<stdin>", line 1, in <module>
> ImportError: No module named js
>>>> import js
>>>>
>
> I can't found module with "imp.find_module" but I can import it with
> standard "import" statement.
>
> Where is my mistake ?
>
> Regards,
> Stephane
> --
> Stéphane Klein <stephane@harobed.org>
> blog: http://stephane-klein.info
> Twitter: http://twitter.com/klein_stephane
> pro: http://www.is-webdesign.com
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web