I'm trying to import a.py file into another.py file and I get the error No module named 'filename'
Here's my directory:
(local files)/app/__init__.py
(local files)/app/routes.py
(local files)/app/errors.py
(local files)/app/forms.py
(local files)/app/apiDnd.py
I'm trying to use apiDnd.py in routes.py
My __init__.py
file:
from flask import Flask
from config import Config
app = Flask(__name__)
app._static_folder = '../static'
app.config.from_object(Config)
from app import routes, errors, apiDnd
My routes.py
file:
from flask import render_template, flash, redirect, url_for, jsonify, request, json
from app import app
import apiDnd
Everything works fine without the import apiDnd
line and that's where the error is.
Replace import apiDnd
in routes.py
with from. import apiDnd
from. import apiDnd
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.