Ex50 First Browser - no module named web

Hi Zed,

I’m having trouble getting the web app working. I have multiple version of python on my machine. I spent some time yesterday ensuring web/ was downloaded in the same directory as the python instance I’m calling.

Unfortunately, it’s still not working. Do you have any tips on how I can get it working, or clean things up?

Seans-MacBook:bin sean_mc$ ls
2to3@               easy_install*       metadata.json       structures.py
2to3-3.6@           easy_install-3.6*   models.py           template.py
DESCRIPTION.rst     exceptions.py       net.py              test.py
INSTALLER           form.py             packages.py         top_level.txt
METADATA            galileod*           pip*                tree-cli*
RECORD              gdbm_dump@          pip3*               unlzma@
WHEEL               gdbm_load@          pip3.6*             unxz@
__init__.py         gdbmtool@           pydoc3@             utils.py
__pycache__/        help.py             pydoc3.6@           web/
__version__.py      hooks.py            python*             webapi.py
_internal_utils.py  http.py             python23.py         webopenid.py
adapters.py         httpserver.py       python3@            wheel3@
api.py              idle3@              python3-32@         wsgi.py
apm@                idle3.6@            python3-config@     wsgiserver/
application.py      lzcat@              python3.6@          xz@
atom@               lzcmp@              python3.6-32@       xzcat@
auth.py             lzdiff@             python3.6-config@   xzcmp@
brew@               lzegrep@            python3.6m@         xzdec@
browser.py          lzfgrep@            python3.6m-config@  xzdiff@
certs.py            lzgrep@             pyvenv@             xzegrep@
compat.py           lzless@             pyvenv-3.6@         xzfgrep@
contrib/            lzma@               requests/           xzgrep@
cookies.py          lzmadec@            session.py          xzless@
db.py               lzmainfo@           sessions.py         xzmore@
debugerror.py       lzmore@             status_codes.py
Seans-MacBook:bin sean_mc$ 
Seans-MacBook:bin sean_mc$ pwd

/usr/local/bin

Seans-MacBook:bin sean_mc$ popd

~/mystuff/projects/gothonweb

Seans-MacBook:gothonweb sean_mc$ python bin/app.py

Traceback (most recent call last):

File "bin/app.py", line 1, in <module>

import web

ImportError: No module named web

Seans-MacBook:gothonweb sean_mc$

Hello @smcmann

From what I see in here I guess you have no virtual enviorment.
This can help you with the problem with several versions of python. Once created this enviorment contains only the python version you choose.

python3.6 -m venv ./my_venv

I think you should put it in your skeleton folder if you have followed the structure in ex46.

This creates a folder named my_venv.
Do not put anything in there!
“venv” needs these to run this enviorment.

Activate this with:

source my_venv/bin/activate

You can see the name of the venv to the left in your terminal. My looks like this.

(my_venv) ulfen@ulfen~/lpthw/gothonweb/>

Once created and activated you can install dependices you need for your project.
In this case it would be:

pip install flask

I hope this helps

Thanks @ulfen69. I’ll try this when I get home. My office firewall is preventing me from installing flask.

By downloading flask, will I be running this app with python, or python3.6?

Actually, I also see that maybe you’ve got a totally different location for the app.py. It looks like you went into the python distribution’s bin directory and put it there? Like /usr/local/python3.6/bin/ ?

If that’s the case then you definitely need to delete that file, then go into the instructions again and create the project in your home directory only. Watch the video for sure as it’s easier to see what’s going on.