ImportError: "unknown location"

Hi all,

So, it looks like I’ve taken a few steps backward. I’m trying to re-familiarize myself with my and modules, but I can’t import the any of my functions from After importing the module, I’ll try to import the peek functions and get this error message in the interpreter:

ImportError: cannot import name 'peek' from 'parser' (unknown location)

I’ve even gone in and used the built in globals() function call to make sure it’s in my global namespace:

'peek': <function peek at 0x0000016896F1C1E0>

Sure enough, it’s there. In fact, the only object I’m able to import from the module is the ParserError exception. I’ve made sure there aren’t any improper indentations, misspellings, etc. I also can’t find anything online to help me out with an object having an “unknown location.”

For reference, here’s my directory tree:

│   └───templates

Everything except for my module is in the gorthonweb subdirectory. I’m also not sure if this would cause anything, but I’ve actually been storing code in my module too. It looks like this:

from flask import Flask
from flask_sqlalchemy import SQLAlchemy
from flask_bcrypt import Bcrypt
from flask_login import LoginManager

app = Flask(__name__)
app.config['SECRET_KEY'] = 'random numbers'
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///game.db'
db = SQLAlchemy(app)
bcrypt = Bcrypt(app)
login_manager = LoginManager(app)

from gorthonweb import routes

P.S. I’ve also tried setting my PYTHONPATH and I am aware I misspelled gothon (gorthon), but I’ve been spelling it that way everywhere.

So templates is in gorthonweb also?
If it’s a subdirectory of gorthonweb, check if it has an file in it. If it does and you don’t have an in the directory of your parser module, you’ll get an error.
So the solution would be to add an or delete the one in the templates. You eiter have them everywhere or not.
Check this out:

That’s what each directory looks like. I only have an file in the gorthonweb directory (where my module is). Also, I’m able to import everything from my module just fine (which is why I’m very confused). I don’t have one in the root directory, where my module is.

Show me where you do the import of the parser module, exactly how you import “peek”

I also forgot to mention the problem isn’t just peek, it’s with everything except for the ParserError class.

Right now I’m doing it in the python interpreter. I also went ahead and tried running it through a script:

from lexicon import lexicon, scan
from parser import *

words = 'the player goes north'
scanned_words = scan(words)
parsed_words = parse_sentence(scanned_words)


It returns this error message when I try to run the script:

Traceback (most recent call last):
  File "", line 6, in <module>
    parsed_words = parse_sentence(scanned_words)
NameError: name 'parse_sentence' is not defined

Why don’t you do:
import parser as pars
then do: parsed_words = pars.parse_sentence(scanned_words)

Still returns the same message. :frowning:

Wait… Where is located?
Ahhh! I think the name of the module is the problem! Python already has a module parser for sure. Try renaming it.
There must be an issue with script location or Python path in Windows.


It’s located in the same directory as all of the other ones. I just created it temporarily.

And I think that did it! Wow! I guess there’s a naming confliction then with something they included in 3.7. I changed it to and it worked.

Now I have to re-familiarize myself with this. But, at least I can access the objects finally. :slight_smile:

Thanks, @io_io!


No problem, glad you solved it! :smiley:

1 Like

Yes! That’s exactly what I was about to say. I totally forgot about that. Python is terrible for not putting builtins into a module.

I think I need to go read up on all the changes made in 3.7. This is now the second problem I’ve had due to the update.

I am still using 3.6 and not planning to change soon. Didn’t even install 3.7

1 Like

Don’t blame you there.

It’s very interesting.

Yeah it’s good practice to read up in release notes before an upgrade, especially a dot upgrade like .6 to .7

I get along find with 3.7 actually.

hello lm facing a challenge with import error unkown location too
"ImportError: cannot import name ‘GazeTracking’ from ‘gaze_tracking’ (unknown location)"is the messagel get when l run tho gaze tracking is in the same file as

thats my snippet for can you help

A free service run by Zed A. Shaw for