Cannot use "from X import Y"

Issue #87 invalid
Former user created an issue

You need two files, and, if one file imports the other and the other uses the import method of "from X import Y" then there will be an unexpected import error, an error that as you can imagine is absent from running the program normally.

First file: {{{ #!python

#!/usr/bin/env python3 import file_2 }}}

Second file: {{{ #!python

#!/usr/bin/env python3 from collections import OrderedDict }}}

Here is the error I receive: {{{ #!python

Traceback (most recent call last): File "", line 2, in <module> import file_2 File "", line 2, in <module> from collections import OrderedDict ImportError: cannot import name OrderedDict }}}

Comments (3)

  1. Ned Batchelder repo owner

    I can't reproduce your problem. Can you provide more details, such as which platform and Python version you are using? I tried it with Python 3.1 on Windows.

  2. Former user Account Deleted

    Python 3.1.1 (r311:74543, Aug 24 2009, 18:44:04)


    Python 2.6.1 (r261:67515, Feb 11 2010, 00:51:29)

    I poked a little further and running it using Python2.6 it comes up with the same import error which then causes said error. Coverage is clearly picking up the system default of Python2.6, how do I force Coverage to use Python3 without altering the default system preference?

  3. Ned Batchelder repo owner

    The "coverage" command is installed in the Scripts or Tools directory of your Python interpreter. If you aren't finding the proper coverage command, you might want to adjust your system path. There's also a in that directory as well, which you can invoke with an explicit python interpreter:

    $ /path/to/python /path/to/ run blah blah

  4. Log in to comment