Python 3.8 and __init__.py in views directory

18 views
Skip to first unread message

Sydo Luciani

unread,
Mar 24, 2020, 11:12:36 PM3/24/20
to pylons-discuss
No problem with python 3.5 environment, but missing views/__init__.py, throws below errors in Python 3.8.

Even including relative path to view module in config.scan('.module_name/views/view_module') has no effect.

Error starts with:
pyramid.httpexceptions.HTTPNotFound: The resource could not be found.
During handling of the above exception, another exception occurred:

And trace ends with:
  File "/usr/lib/python3.8/posixpath.py", line 152, in dirname
    p = os.fspath(p)


Is it by design ?

Michael Merickel

unread,
Mar 25, 2020, 11:28:47 AM3/25/20
to pylons-...@googlegroups.com
Sorry can you give more context? Did you delete the __init__.py in your views folder? If so, I would expect some issues.

--
You received this message because you are subscribed to the Google Groups "pylons-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pylons-discus...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pylons-discuss/7edc8353-96b9-4bcc-85eb-372f049e6934%40googlegroups.com.

Sydo Luciani

unread,
Mar 25, 2020, 2:06:26 PM3/25/20
to pylons-...@googlegroups.com
Yes, I was missing __init__.py in views folder, but didn't have any problem while working in Python 3.5 environment,
error started when switched to Python 3.7 and Python 3.8, and creating __init__ fixed the issue.

The different behavior brought up curiosity.




Jonathan Vanasco

unread,
Mar 25, 2020, 3:23:06 PM3/25/20
to pylons-discuss

Stuff like this often happens because Python has a compiled/cached version. Under Python2,  `.pyc` files were in the same directory as the `.py` file ; under Python3 they are in a `__pycache__` directory and versioned to the interpreter.

you probably had a `views/__pycache__/__init__.cpython-35.pyc` file, which python 3.5 picked up but 3.7 and 3.8 will not.

Sydo Luciani

unread,
Mar 25, 2020, 6:09:11 PM3/25/20
to pylons-discuss
Sorry, no , after deleting __pycache__ and reinstalling app using pip install -e .
it worked with Python 3.5 but not with python 3.8.

p = os.fspath(p)
TypeError: expected str, bytes or os.PathLike object, not NoneType

Probably not important since recreating __init__.py fixes the problem
but apparently something has changed since Python 3.6.
Reply all
Reply to author
Forward
0 new messages