Error when importing the same directory files python

When you import the, python interpreter only (a list, you can print out to see) in sys.path variable path inside the package to find a possible match or module.

The difference between a package with a common folder that, package folder more than a __init__.py file. In other words, if you add a __init__.py file in a folder, the python would think that this is a python folder in the package.

__Init__.py file content may be empty (package inside this module is necessary, .py file is the module, the knowledge to know), it just tells python current folder is a python in the package. Of course, you can add this __init__.py module inside some of the code that will run this package at import time, that is the next package __init__.py module, will be in the import package, immediately will never indented the place to start executing code.

So, make sure that the directory you want to import the py file comes from a __init__.py file.

Guess you like

Origin www.cnblogs.com/wangconnor/p/11955817.html