Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #8823
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder2.enfer-du-nord.net!feeder.news-service.com!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <ericsnowcurrently@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.005 |
| X-Spam-Evidence | '*H*': 0.99; '*S*': 0.00; 'subject:module': 0.04; 'importerror:': 0.07; '>>>>': 0.09; 'function:': 0.09; 'statement.': 0.09; 'subject:don': 0.09; 'am,': 0.13; 'wrote:': 0.15; '"import"': 0.16; 'imp': 0.16; 'pypi.': 0.16; 'stephane': 0.16; 'subject:import': 0.16; 'cc:addr:python-list': 0.16; '(most': 0.21; 'cc:2**0': 0.21; 'blog:': 0.22; 'cc:no real name:2**0': 0.22; 'header:In-Reply-To:1': 0.22; 'received:209.85.215.46': 0.23; 'received:mail- ew0-f46.google.com': 0.23; 'sfxlen:0': 0.23; 'tue,': 0.23; 'traceback': 0.25; 'url:mailman': 0.27; 'message- id:@mail.gmail.com': 0.28; 'import': 0.29; 'cc:addr:python.org': 0.30; 'module': 0.30; 'hi,': 0.31; 'url:listinfo': 0.32; 'named': 0.32; "can't": 0.34; 'last):': 0.35; 'module.': 0.35; 'subject: ?': 0.35; 'here,': 0.35; 'install': 0.36; 'skip:" 10': 0.36; 'url:python': 0.37; 'some': 0.37; 'but': 0.37; 'received:google.com': 0.38; 'subject:can': 0.38; 'received:209.85': 0.38; 'url:org': 0.38; 'subject:: ': 0.38; 'received:209': 0.40; 'where': 0.40; 'subject:but': 0.67; 'subject:this': 0.74; 'url:info': 0.75; 'to:charset:iso-8859-1': 0.82; 'subject:found': 0.91; 'klein': 0.93 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; bh=9TrATc21kc4pd9S+wAmz0U7/ij1UHuurKesHTvVonBk=; b=eSoOP4GRYp4gqLyJ5b3csoC8kxjc78y4W422lm3XGGS3kliU6E8D4TEacs1NXsDZ2z btSDAtpk3cbXJHw1+73YGWSE4Wr1uWmp0AIC+la9hFAePLh16t5xZI8RbrTuLMOApRl8 HqYq3IwCTwgQKYSOOhQEj1VaW3EJggJTa02Ac= |
| MIME-Version | 1.0 |
| In-Reply-To | <iuueur$7j9$1@dough.gmane.org> |
| References | <iuueur$7j9$1@dough.gmane.org> |
| Date | Tue, 5 Jul 2011 07:44:00 -0600 |
| Subject | Re: imp.find_module don't found my module but standard import statement can import this module… why ? |
| From | Eric Snow <ericsnowcurrently@gmail.com> |
| To | Stéphane Klein <stephane@harobed.org> |
| Content-Type | text/plain; charset=ISO-8859-1 |
| Content-Transfer-Encoding | quoted-printable |
| Cc | python-list@python.org |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.12 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.626.1309873442.1164.python-list@python.org> (permalink) |
| Lines | 49 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1309873442 news.xs4all.nl 21876 [2001:888:2000:d::a6]:60141 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | x330-a1.tempe.blueboxinc.net comp.lang.python:8823 |
Show key headers only | View raw
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
>
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
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
csiph-web