Python – Module Not Found

All modules in Python have to have a certain directory structure. You can find details here. Create an empty file called __init__.py under the model directory, such that your directory structure would look something like that: Also in your hello-world.py file change the import statement to the following: That should fix it P.S.: If you are placing your model directory in some other location … Read more

How do I unload (reload) a Python module?

You can reload a module when it has already been imported by using importlib.reload(): In Python 2, reload was a builtin. In Python 3, it was moved to the imp module. In 3.4, imp was deprecated in favor of importlib. When targeting 3 or later, either reference the appropriate module when calling reload or import it. I think that this is what you want. Web servers like Django’s development … Read more

Importing modules from parent folder

It seems that the problem is not related to the module being in a parent directory or anything like that. You need to add the directory that contains ptdraft to PYTHONPATH You said that import nib worked with you, that probably means that you added ptdraft itself (not its parent) to PYTHONPATH.

Importing modules from parent folder

It seems that the problem is not related to the module being in a parent directory or anything like that. You need to add the directory that contains ptdraft to PYTHONPATH You said that import nib worked with you, that probably means that you added ptdraft itself (not its parent) to PYTHONPATH.

What is __init__.py for?

It used to be a required part of a package (old, pre-3.3 “regular package”, not newer 3.3+ “namespace package”). Here’s the documentation. Python defines two types of packages, regular packages and namespace packages. Regular packages are traditional packages as they existed in Python 3.2 and earlier. A regular package is typically implemented as a directory … Read more

What is __init__.py for?

It used to be a required part of a package (old, pre-3.3 “regular package”, not newer 3.3+ “namespace package”). Here’s the documentation. Python defines two types of packages, regular packages and namespace packages. Regular packages are traditional packages as they existed in Python 3.2 and earlier. A regular package is typically implemented as a directory … Read more