Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Import statements -- qualify with diylisp? #2

Closed
kevinushey opened this issue May 5, 2014 · 5 comments
Closed

Import statements -- qualify with diylisp? #2

kevinushey opened this issue May 5, 2014 · 5 comments

Comments

@kevinushey
Copy link
Contributor

My initial attempt at running tests gave me the following error (following from the instructions):

kevinushey@Kevin-MBP:~/git/diy-lisp$ nosetests tests/test_1_parsing.py --stop

======================================================================
ERROR: Failure: ImportError (cannot import name 'is_boolean')
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/local/lib/python3.4/site-packages/nose/failure.py", line 39, in runTest
    raise self.exc_val.with_traceback(self.tb)
  File "/usr/local/lib/python3.4/site-packages/nose/loader.py", line 414, in loadTestsFromName
    addr.filename, addr.module)
  File "/usr/local/lib/python3.4/site-packages/nose/importer.py", line 47, in importFromPath
    return self.importFromDir(dir_path, fqname)
  File "/usr/local/lib/python3.4/site-packages/nose/importer.py", line 94, in importFromDir
    mod = load_module(part_fqname, fh, filename, desc)
  File "/usr/local/Cellar/python3/3.4.0_1/Frameworks/Python.framework/Versions/3.4/lib/python3.4/imp.py", line 235, in load_module
    return load_source(name, filename, file)
  File "/usr/local/Cellar/python3/3.4.0_1/Frameworks/Python.framework/Versions/3.4/lib/python3.4/imp.py", line 171, in load_source
    module = methods.load()
  File "<frozen importlib._bootstrap>", line 1220, in load
  File "<frozen importlib._bootstrap>", line 1200, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 1129, in _exec
  File "<frozen importlib._bootstrap>", line 1448, in exec_module
  File "<frozen importlib._bootstrap>", line 321, in _call_with_frames_removed
  File "/Users/kevinushey/git/diy-lisp/tests/test_1_parsing.py", line 5, in <module>
    from diylisp.parser import parse, unparse
  File "/Users/kevinushey/git/diy-lisp/diylisp/parser.py", line 4, in <module>
    from ast import is_boolean, is_list
ImportError: cannot import name 'is_boolean'

Should we be using from diylisp.ast import ... instead; ie, qualifying with the directory?

(My lack of proficiency with Python is probably showing here...)

@kvalle
Copy link
Owner

kvalle commented May 5, 2014

My best guess is that your problem is somehow caused by the tests not working as expected with Python 3. I've used Python 2.7.3 all the while working on this. Could you check to see if that works any better?

@kvalle
Copy link
Owner

kvalle commented May 5, 2014

Just had a chance to check. Indeed it seems this problem occurs when using Python 3. @kevinushey I suggest you use Python 2.7 instead. I'll add a note about that to the README as well.

Let me know if you have any other problems.

@kvalle kvalle closed this as completed May 5, 2014
@kevinushey
Copy link
Contributor Author

Gotcha -- thanks for investigating!

(Now through part 2 of the lessons; it's going quite smoothly. Thanks for putting this together!)

@AndrejStanisev
Copy link

I'm having the same problem with Python 2.7.6.

@kvalle
Copy link
Owner

kvalle commented May 8, 2014

@Nefron That's strange. I wouldn't expect 2.7.6 to handle imports any different from 2.7.3. Are you sure you're running the nosetests command from the project root directory? And could you post the output?

codecop added a commit to codecop/diy-lang that referenced this issue Mar 5, 2017
codecop added a commit to codecop/diy-lang that referenced this issue May 24, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants