Forums

[Web App]:urllib.parse.unquote is not a attribute

I'm working on a forum-ish web app. I keep getting the error

2018-11-02 04:48:29,582: AttributeError: module 'urllib.parse' has no attribute 'unqoute'
2018-11-02 04:48:31,163: [2018-11-02 04:48:31,163] ERROR in app: Exception on /forum/test [GET]
2018-11-02 04:48:31,164: Traceback (most recent call last):
2018-11-02 04:48:31,164:   File "/usr/local/lib/python3.6/dist-packages/flask/app.py", line 1982, in wsgi_app
2018-11-02 04:48:31,164:     response = self.full_dispatch_request()
2018-11-02 04:48:31,164:   File "/usr/local/lib/python3.6/dist-packages/flask/app.py", line 1614, in full_dispatch_request
2018-11-02 04:48:31,165:     rv = self.handle_user_exception(e)
2018-11-02 04:48:31,165:   File "/usr/local/lib/python3.6/dist-packages/flask/app.py", line 1517, in handle_user_exception
2018-11-02 04:48:31,165:     reraise(exc_type, exc_value, tb)
2018-11-02 04:48:31,165:   File "/usr/local/lib/python3.6/dist-packages/flask/_compat.py", line 33, in reraise
2018-11-02 04:48:31,166:     raise value
2018-11-02 04:48:31,166:   File "/usr/local/lib/python3.6/dist-packages/flask/app.py", line 1612, in full_dispatch_request
2018-11-02 04:48:31,166:     rv = self.dispatch_request()
2018-11-02 04:48:31,166:   File "/usr/local/lib/python3.6/dist-packages/flask/app.py", line 1598, in dispatch_request
2018-11-02 04:48:31,166:     return self.view_functions[rule.endpoint](**req.view_args)
2018-11-02 04:48:31,167:   File "/home/acehouse/mysite/flask_app.py", line 31, in showforum 
2018-11-02 04:48:31,167:     name=urllib.parse.unqoute(name)
2018-11-02 04:48:31,167: AttributeError: module 'urllib.parse' has no attribute 'unqoute'

Sorry about the error formatting

[edit by admin: fixed error formatting]

I have also importted urllib.parse

I may have spotted the error. Running a dir of urllib.parse returns

['DefragResult', 'DefragResultBytes', 'MAX_CACHE_SIZE', 'ParseResult', 'ParseResultBytes', 'Quoter', 'ResultBase', 'SplitResult', 'SplitResultBytes', '_ALWAYS_SAFE', '_ALWAYS_SAFE_BYTES', '_DefragResultBase', '_NetlocResultMixinBase', '_NetlocResultMixinBytes', '_NetlocResultMixinStr', '_ParseResultBase', '_ResultMixinBytes', '_ResultMixinStr', '_SplitResultBase', '__all__', '__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__spec__', '_asciire', '_coerce_args', '_decode_args', '_encode_result', '_hexdig', '_hextobyte', '_hostprog', '_implicit_encoding', '_implicit_errors', '_noop', '_parse_cache', '_portprog', '_safe_quoters', '_splitnetloc', '_splitparams', '_typeprog', 'clear_cache', 'collections', 'namedtuple', 'non_hierarchical', 'parse_qs', 'parse_qsl', 'quote', 'quote_from_bytes', 'quote_plus', 're', 'scheme_chars', 'splitattr', 'split

The last part is complete for some reason

It works fine in the console but doesn't work in the web app. The python versions are matching.

Are you somehow overwriting urllib.parse in your web app? Maybe you have another module that you've called urllib? Maybe you're assigning a variable to urllib or urllib.parse (possibly accidentally)?

Is that dir above of urllib.parse in the web app or from the console? Compare the dirs from the 2 envrionments. Also try looking at urllib.file and urllib.parse.file in both environments.

I've checked over my code for overwritting. The dirs seem fine when I output them on the webpage but I haven't tested urllib.file yet. Thanks though! I'm posting this from my main account.

[DEBUG] dir(urllib.parse) = ['DefragResult', 'DefragResultBytes', 'MAX_CACHE_SIZE', 'ParseResult', 'ParseResultBytes', 'Quoter', 'ResultBase', 'SplitResult', 'SplitResultBytes', '_ALWAYS_SAFE', '_ALWAYS_SAFE_BYTES', '_DefragResultBase', '_NetlocResultMixinBase', '_NetlocResultMixinBytes', '_NetlocResultMixinStr', '_ParseResultBase', '_ResultMixinBytes', '_ResultMixinStr', '_SplitResultBase', 'all', 'builtins', 'cached', 'doc', 'file', 'loader', 'name', 'package', 'spec', '_asciire', '_coerce_args', '_decode_args', '_encode_result', '_hexdig', '_hextobyte', '_hostprog', '_implicit_encoding', '_implicit_errors', '_noop', '_parse_cache', '_portprog', '_safe_quoters', '_splitnetloc', '_splitparams', '_typeprog', 'clear_cache', 'collections', 'namedtuple', 'non_hierarchical', 'parse_qs', 'parse_qsl', 'quote', 'quote_from_bytes', 'quote_plus', 're', 'scheme_chars', 'splitattr', 'splithost', 'splitnport', 'splitpasswd', 'splitport', 'splitquery', 'splittag', 'splittype', 'splituser', 'splitvalue', 'sys', 'to_bytes', 'unquote', 'unquote_plus', 'unquote_to_bytes', 'unwrap', 'urldefrag', 'urlencode', 'urljoin', 'urlparse', 'urlsplit', 'urlunparse', 'urlunsplit', 'uses_fragment', 'uses_netloc', 'uses_params', 'uses_query', 'uses_relative'] [DEBUG] urllib.parse.file = /usr/lib/python3.6/urllib/parse.py

Seems to be the same. I don't know why it keeps saying unqoute is not a attribute though.

I took the python 3 code from here

The function is called unquote but your error message says

AttributeError: module 'urllib.parse' has no attribute 'unqoute'

-- note the transposed 'o' and 'u'.

My bad

No problem -- glad we could help, anyway.