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

examples/flask_demo.mochi failed with AttributeError: 'NoneType' object has no attribute 'loader' #24

Open
tlvu opened this issue Apr 15, 2015 · 12 comments

Comments

@tlvu
Copy link
Contributor

tlvu commented Apr 15, 2015

Traceback (most recent call last):
File "/root/venv/mochi/bin/mochi", line 9, in
load_entry_point('mochi==0.2.1', 'console_scripts', 'mochi')()
File "/root/venv/mochi/lib/python3.4/site-packages/mochi-0.2.1-py3.4.egg/mochi/core/main.py", line 192, in main
load_file(args.file, global_env)
File "/root/venv/mochi/lib/python3.4/site-packages/mochi-0.2.1-py3.4.egg/mochi/core/main.py", line 49, in load_file
return exec(compile_file(path), env)
File "flask_demo.mochi", line 3, in
app = Flask('demo')
File "/root/venv/mochi/lib/python3.4/site-packages/flask/app.py", line 319, in init
template_folder=template_folder)
File "/root/venv/mochi/lib/python3.4/site-packages/flask/helpers.py", line 741, in init
self.root_path = get_root_path(self.import_name)
File "/root/venv/mochi/lib/python3.4/site-packages/flask/helpers.py", line 631, in get_root_path
loader = pkgutil.get_loader(import_name)
File "/usr/lib/python3.4/pkgutil.py", line 467, in get_loader
return find_loader(fullname)
File "/usr/lib/python3.4/pkgutil.py", line 488, in find_loader
return spec.loader
AttributeError: 'NoneType' object has no attribute 'loader'

@pya
Copy link
Contributor

pya commented Apr 16, 2015

Works for me.

$ mochi flask_demo.mochi 
 * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)

makes "Hello World" show up with http://localhost:5000/. I have not updated from upstream yet after the split-up of the lexer and parser by @fabianvf #19 was merged.

@fabianvf
Copy link
Contributor

Yes, that may have broken something (was a WIP PR, forgot we don't have the same repo rules and didn't think it would get merged). My later PRs should fix whatever problems may have been introduced.

@pya
Copy link
Contributor

pya commented Apr 16, 2015

Ok. New status: Likely closed with pending PR. ;)

@i2y
Copy link
Owner

i2y commented Apr 16, 2015

I run the examples/flask_demo.mochi after merging the PR to master branch, seemed to have no problem. Then I pushed it to remote repo.

@tlvu
Copy link
Contributor Author

tlvu commented Apr 17, 2015

Looks like I have the problem and you guys don't ! Does that sounds familiar with "it works on my machine and not yours". This is exactly the problem Docker was created to address.

I currently have this commit checked out:

commit 1a36837ed6615cad4837eba21c96951e62dc042c
Merge: 9fcd0d1 9abd341
Author: i2y <[email protected]>
Date:   Fri Apr 17 07:16:05 2015 +0900
    Merge branch 'tlvu-docker-support'

And I run the test this way (documented on the Docker hub page of the image):

cd <the checkout root of your mochi>
docker run -i -t --rm -v `pwd`:/files:ro -v `pwd`/mochi:/venv/mochi/lib/python3.4/si
te-packages/mochi tlvu/mochi /files/examples/flask_demo.mochi

And I still have the problem.

Don't believe that it is running the exact code from that commit? Change something in the code purposely to make it break and see if it breaks where you expect it.

The goal of the exercise is to show you guys that Docker really provide a reproducible runtime environment. If it fails on my machine and you use the same Docker image as me, I should also fail for you, no excuse.

I think the Docker image is missing something but I have no clues right now. I think you guys are all running on Mac and I am the only one on Linux so it's hard to compare.

@i2y
Copy link
Owner

i2y commented Apr 17, 2015

@tlvu Thank you. You are right.
I have always developed Mochi on Mac.
I run the flask_demo.mochi on your Docker image (on Ubuntu).
And I also have the problem.
The problem is easily reproducible with your Docker image.

@i2y
Copy link
Owner

i2y commented Apr 17, 2015

I got the results of running the following on Ubuntu (without Docker).

> uname -a
Linux ubuntu 3.13.0-34-generic #60-Ubuntu SMP Wed Aug 13 15:45:27 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux
> python3 —version
Python 3.4.0
> pip3 install mochi
> pip3 install flask
> cat examples/flask_demo.py
from flask import Flask

app = Flask('demo')

@app.route('/')
def hello():
    return 'Hello World!'

app.run()
> python3 examples/flask_demo.py
Traceback (most recent call last):
  File "examples/flask_demo.py", line 3, in <module>
    app = Flask('demo')
  File "/usr/local/lib/python3.4/dist-packages/flask/app.py", line 319, in __init__
    template_folder=template_folder)
  File "/usr/local/lib/python3.4/dist-packages/flask/helpers.py", line 741, in __init__
    self.root_path = get_root_path(self.import_name)
  File "/usr/local/lib/python3.4/dist-packages/flask/helpers.py", line 631, in get_root_path
    loader = pkgutil.get_loader(import_name)
  File "/usr/lib/python3.4/pkgutil.py", line 467, in get_loader
    return find_loader(fullname)
  File "/usr/lib/python3.4/pkgutil.py", line 488, in find_loader
    return spec.loader
AttributeError: 'NoneType' object has no attribute 'loader'

@i2y
Copy link
Owner

i2y commented Apr 17, 2015

I think that we have not the problem on Python 3.4.1+.
pallets/flask#1011

@i2y
Copy link
Owner

i2y commented Apr 17, 2015

I've actually tried now on Python 3.4.1, 3.4.2 and 3.4.3.
I have the probrem on Python 3.4.1.
I don't have the probrem on Python 3.4.2 and 3.4.3.

@tlvu
Copy link
Contributor Author

tlvu commented Apr 18, 2015

Ah good to know that the Docker image is doing its job properly: reproducible runtime environment (that image has Python 3.4.0)

When I have time I'll build a new Docker image with a newer Python so we have a working image for any newcomers to quickly try mochi out.

@i2y
Copy link
Owner

i2y commented Apr 18, 2015

That sounds good!
I used the first time Docker for this issue and got to like it.

@pya
Copy link
Contributor

pya commented Apr 18, 2015

Seems like a testing granularity based on minor versions is not enough. Having tests runs for different revisions that are in common use might be needed. Python 3.4.0 through 3.4.3 are the first candidates here.

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

4 participants