Lp3thw ex52 import errors

Hello,
I’m having some trouble in ex.52 with some import errors.
First my directory structure:

My import commands in tests and files are these:

planisphere_tests.py:

from nose.tools import *
from gothonweb.planisphere import *

app_tests.py:

from nose.tools import *
from gothonweb.app import *

app.py

from flask import Flask, session, redirect, url_for, escape, request
from flask import render_template
from gothonweb import planisphere

Now, with imports like these i can run tests perfectly with:
nosetests app_tests.py
or
nosetests planisphere_tests.py

from the /tests directory. The problem is i can’t run the app.py file. When I go cd … and then ‘python app.py’ i get import error:

file 'app.py'
from gothonweb import planisphere
ImportError

I can change the import commands for this to work but then my tests will have an import error. I tried ‘$env:PYTHONPATH = “$env:PYTHONPATH;.”’ but still not working.

I haven’t been able to fix this.
Where is my mistake?

Thank you.

In your screenshot it looks like you have an __init__.py file in the root (top) of the project. Delete that. Then delete the __pycache__ directory too just to be sure. Try that. Also, maybe it’s time to switch to PyTest instead:

https://docs.pytest.org/en/stable/

A free service run by Zed A. Shaw for learncodethehardway.org.