Home>

File structure
master
| —data
| —models
| | —Alex.py

| —src
| | —create_as.py

Please write your question in detail here.

I want to import another file.

I want to run create_as.py
In create_as.py, in order to use the class "Alex ()" in Alex.py
You need to import Alex.py.

■■ The following error message occurred while implementing the function.

Error message

No module named'models'

Corresponding source code
Source code


// Part of the code (contents of create_as.py)
import sys
sys.path.append ('/ Users/username/Downloads/master/models /')
from models import Alex

// ↑ import part

What I tried

Put "create_as.py" in master,
When I changed "from models import Alex" to "import models.Alex" and executed it, I got an error in this part, so I think it is a path problem.

Please describe here what you have tried for the problem.

Supplementary information (FW/tool version, etc.)

python 3.

Please provide more detailed information here.